home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / programming / gcc / gcc2.7.0 / gcc270_src.lha / gcc-2.7.0-amiga / config / alpha / alpha.md < prev    next >
Encoding:
Text File  |  1995-06-15  |  110.0 KB  |  3,760 lines

  1. ;; Machine description for DEC Alpha for GNU C compiler
  2. ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
  3. ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
  4.  
  5. ;; This file is part of GNU CC.
  6.  
  7. ;; GNU CC is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; GNU CC is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;; GNU General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU CC; see the file COPYING.  If not, write to
  19. ;; the Free Software Foundation, 59 Temple Place - Suite 330,
  20. ;; Boston, MA 02111-1307, USA.
  21.  
  22. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  23.  
  24. ;; Define an insn type attribute.  This is used in function unit delay
  25. ;; computations, among other purposes.  For the most part, we use the names
  26. ;; defined in the EV4 documentation, but add a few that we have to know about
  27. ;; separately.
  28.  
  29. (define_attr "type"
  30.   "ld,st,ibr,fbr,jsr,iaddlog,shiftcm,icmp,imull,imulq,fpop,fdivs,fdivt,ldsym,isubr"
  31.   (const_string "shiftcm"))
  32.  
  33. ;; We include four function units: ABOX, which computes the address,
  34. ;; BBOX, used for branches, EBOX, used for integer operations, and FBOX,
  35. ;; used for FP operations.
  36. ;;
  37. ;; We assume that we have been successful in getting double issues and
  38. ;; hence multiply all costs by two insns per cycle.  The minimum time in
  39. ;; a function unit is 2 cycle, which will tend to produce the double
  40. ;; issues.
  41.  
  42. ;; Memory delivers its result in three cycles.
  43. (define_function_unit "abox" 1 0 (eq_attr "type" "ld,ldsym,st") 6 2)
  44.  
  45. ;; Branches have no delay cost, but do tie up the unit for two cycles.
  46. (define_function_unit "bbox" 1 1 (eq_attr "type" "ibr,fbr,jsr") 4 4)
  47.  
  48. ;; Arithmetic insns are normally have their results available after two
  49. ;; cycles.  There are a number of exceptions.  They are encoded in
  50. ;; ADJUST_COST.  Some of the other insns have similar exceptions.
  51.  
  52. (define_function_unit "ebox" 1 0 (eq_attr "type" "iaddlog,shiftcm,icmp") 4 2)
  53.  
  54. ;; These really don't take up the integer pipeline, but they do occupy
  55. ;; IBOX1; we approximate here.
  56.  
  57. (define_function_unit "ebox" 1 0 (eq_attr "type" "imull") 42 2)
  58. (define_function_unit "ebox" 1 0 (eq_attr "type" "imulq") 46 2)
  59.  
  60. (define_function_unit "imult" 1 0 (eq_attr "type" "imull") 42 38)
  61. (define_function_unit "imult" 1 0 (eq_attr "type" "imulq") 46 42)
  62.  
  63. (define_function_unit "fbox" 1 0 (eq_attr "type" "fpop") 12 2)
  64.  
  65. (define_function_unit "fbox" 1 0 (eq_attr "type" "fdivs") 68 0)
  66. (define_function_unit "fbox" 1 0 (eq_attr "type" "fdivt") 126 0)
  67.  
  68. (define_function_unit "divider" 1 0 (eq_attr "type" "fdivs") 68 60)
  69. (define_function_unit "divider" 1 0 (eq_attr "type" "fdivt") 126 118)
  70.  
  71. ;; First define the arithmetic insns.  Note that the 32-bit forms also
  72. ;; sign-extend.
  73.  
  74. ;; Note that we can do sign extensions in both FP and integer registers.
  75. ;; However, the result must be in the same type of register as the input.
  76. ;; The register preferencing code can't handle this case very well, so, for
  77. ;; now, don't let the FP case show up here for preferencing.  Also,
  78. ;; sign-extends in FP registers take two instructions.
  79. (define_insn "extendsidi2"
  80.   [(set (match_operand:DI 0 "register_operand" "=r,r,*f")
  81.     (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m,*f")))]
  82.   ""
  83.   "@
  84.    addl %1,$31,%0
  85.    ldl %0,%1
  86.    cvtql %1,%0\;cvtlq %0,%0"
  87.   [(set_attr "type" "iaddlog,ld,fpop")])
  88.  
  89. ;; Do addsi3 the way expand_binop would do if we didn't have one.  This
  90. ;; generates better code.  We have the anonymous addsi3 pattern below in
  91. ;; case combine wants to make it.
  92. (define_expand "addsi3"
  93.   [(set (match_operand:SI 0 "register_operand" "")
  94.     (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
  95.          (match_operand:SI 2 "add_operand" "")))]
  96.   ""
  97.   "
  98. { emit_insn (gen_rtx (SET, VOIDmode, gen_lowpart (DImode, operands[0]),
  99.               gen_rtx (PLUS, DImode,
  100.                    gen_lowpart (DImode, operands[1]),
  101.                    gen_lowpart (DImode, operands[2]))));
  102.   DONE;
  103. } ")
  104.  
  105. (define_insn ""
  106.   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
  107.     (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
  108.          (match_operand:SI 2 "add_operand" "rI,O,K,L")))]
  109.   ""
  110.   "@
  111.    addl %r1,%2,%0
  112.    subl %r1,%n2,%0
  113.    lda %0,%2(%r1)
  114.    ldah %0,%h2(%r1)"
  115.   [(set_attr "type" "iaddlog")])
  116.  
  117. (define_split
  118.   [(set (match_operand:SI 0 "register_operand" "")
  119.     (plus:SI (match_operand:SI 1 "register_operand" "")
  120.          (match_operand:SI 2 "const_int_operand" "")))]
  121.   "! add_operand (operands[2], SImode)"
  122.   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
  123.    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
  124.   "
  125. {
  126.   HOST_WIDE_INT val = INTVAL (operands[2]);
  127.   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
  128.   HOST_WIDE_INT rest = val - low;
  129.  
  130.   operands[3] = GEN_INT (rest);
  131.   operands[4] = GEN_INT (low);
  132. }")
  133.  
  134. (define_insn ""
  135.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  136.     (sign_extend:DI
  137.      (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ,rJ")
  138.           (match_operand:SI 2 "sext_add_operand" "rI,O"))))]
  139.   ""
  140.   "@
  141.    addl %r1,%2,%0
  142.    subl %r1,%n2,%0"
  143.   [(set_attr "type" "iaddlog")])
  144.  
  145. (define_split
  146.   [(set (match_operand:DI 0 "register_operand" "")
  147.     (sign_extend:DI
  148.      (plus:SI (match_operand:SI 1 "register_operand" "")
  149.           (match_operand:SI 2 "const_int_operand" ""))))
  150.    (clobber (match_operand:SI 3 "register_operand" ""))]
  151.   "! sext_add_operand (operands[2], SImode) && INTVAL (operands[2]) > 0
  152.    && INTVAL (operands[2]) % 4 == 0"
  153.   [(set (match_dup 3) (match_dup 4))
  154.    (set (match_dup 0) (sign_extend:DI (plus:SI (mult:SI (match_dup 3)
  155.                             (match_dup 5))
  156.                            (match_dup 1))))]
  157.   "
  158. {
  159.   HOST_WIDE_INT val = INTVAL (operands[2]) / 4;
  160.   int mult = 4;
  161.  
  162.   if (val % 2 == 0)
  163.     val /= 2, mult = 8;
  164.  
  165.   operands[4] = GEN_INT (val);
  166.   operands[5] = GEN_INT (mult);
  167. }")
  168.  
  169. (define_split
  170.   [(set (match_operand:DI 0 "register_operand" "")
  171.     (sign_extend:DI
  172.      (plus:SI (match_operator:SI 1 "comparison_operator"
  173.                      [(match_operand 2 "" "")
  174.                       (match_operand 3 "" "")])
  175.           (match_operand:SI 4 "add_operand" ""))))
  176.    (clobber (match_operand:DI 5 "register_operand" ""))]
  177.   ""
  178.   [(set (match_dup 5) (match_dup 6))
  179.    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 7) (match_dup 4))))]
  180.   "
  181. {
  182.   operands[6] = gen_rtx (GET_CODE (operands[1]), DImode,
  183.              operands[2], operands[3]);
  184.   operands[7] = gen_lowpart (SImode, operands[5]);
  185. }")
  186.  
  187. (define_insn "adddi3"
  188.   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
  189.     (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ")
  190.          (match_operand:DI 2 "add_operand" "rI,O,K,L")))]
  191.   ""
  192.   "@
  193.    addq %r1,%2,%0
  194.    subq %r1,%n2,%0
  195.    lda %0,%2(%r1)
  196.    ldah %0,%h2(%r1)"
  197.   [(set_attr "type" "iaddlog")])
  198.  
  199. ;; Don't do this if we are adjusting SP since we don't want to do
  200. ;; it in two steps. 
  201. (define_split
  202.   [(set (match_operand:DI 0 "register_operand" "")
  203.     (plus:DI (match_operand:DI 1 "register_operand" "")
  204.          (match_operand:DI 2 "const_int_operand" "")))]
  205.   "! add_operand (operands[2], DImode)
  206.    && REGNO (operands[0]) != STACK_POINTER_REGNUM"
  207.   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
  208.    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
  209.   "
  210. {
  211.   HOST_WIDE_INT val = INTVAL (operands[2]);
  212.   HOST_WIDE_INT low = (val & 0xffff) - 2 * (val & 0x8000);
  213.   HOST_WIDE_INT rest = val - low;
  214.  
  215.   operands[3] = GEN_INT (rest);
  216.   operands[4] = GEN_INT (low);
  217. }")
  218.  
  219. (define_insn ""
  220.   [(set (match_operand:SI 0 "register_operand" "=r,r")
  221.     (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ,rJ")
  222.               (match_operand:SI 2 "const48_operand" "I,I"))
  223.          (match_operand:SI 3 "sext_add_operand" "rI,O")))]
  224.   ""
  225.   "@
  226.    s%2addl %r1,%3,%0
  227.    s%2subl %r1,%n3,%0"
  228.   [(set_attr "type" "iaddlog")])
  229.  
  230. (define_insn ""
  231.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  232.     (sign_extend:DI
  233.      (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ,rJ")
  234.                (match_operand:SI 2 "const48_operand" "I,I"))
  235.           (match_operand:SI 3 "sext_add_operand" "rI,O"))))]
  236.   ""
  237.   "@
  238.    s%2addl %r1,%3,%0
  239.    s%2subl %r1,%n3,%0"
  240.   [(set_attr "type" "iaddlog")])
  241.  
  242. (define_split
  243.   [(set (match_operand:DI 0 "register_operand" "")
  244.     (sign_extend:DI
  245.      (plus:SI (mult:SI (match_operator:SI 1 "comparison_operator"
  246.                           [(match_operand 2 "" "")
  247.                            (match_operand 3 "" "")])
  248.                (match_operand:SI 4 "const48_operand" ""))
  249.           (match_operand:SI 5 "add_operand" ""))))
  250.    (clobber (match_operand:DI 6 "register_operand" ""))]
  251.   ""
  252.   [(set (match_dup 6) (match_dup 7))
  253.    (set (match_dup 0)
  254.     (sign_extend:DI (plus:SI (mult:SI (match_dup 8) (match_dup 4))
  255.                  (match_dup 5))))]
  256.   "
  257. {
  258.   operands[7] = gen_rtx (GET_CODE (operands[1]), DImode,
  259.              operands[2], operands[3]);
  260.   operands[8] = gen_lowpart (SImode, operands[6]);
  261. }")
  262.  
  263. (define_insn ""
  264.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  265.     (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
  266.               (match_operand:DI 2 "const48_operand" "I,I"))
  267.          (match_operand:DI 3 "reg_or_8bit_operand" "rI,O")))]
  268.   ""
  269.   "@
  270.    s%2addq %r1,%3,%0
  271.    s%2subq %1,%n3,%0"
  272.   [(set_attr "type" "iaddlog")])
  273.  
  274. ;; These variants of the above insns can occur if the third operand
  275. ;; is the frame pointer.  This is a kludge, but there doesn't
  276. ;; seem to be a way around it.  Only recognize them while reloading.
  277.  
  278. (define_insn ""
  279.   [(set (match_operand:DI 0 "some_operand" "=&r")
  280.     (plus:DI (plus:DI (match_operand:DI 1 "some_operand" "r")
  281.               (match_operand:DI 2 "some_operand" "r"))
  282.          (match_operand:DI 3 "some_operand" "rIOKL")))]
  283.   "reload_in_progress"
  284.   "#"
  285.   [(set_attr "type" "iaddlog")])
  286.  
  287. (define_split
  288.   [(set (match_operand:DI 0 "register_operand" "")
  289.     (plus:DI (plus:DI (match_operand:DI 1 "register_operand" "")
  290.               (match_operand:DI 2 "register_operand" ""))
  291.          (match_operand:DI 3 "add_operand" "")))]
  292.   "reload_completed"
  293.   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
  294.    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
  295.   "")
  296.                        
  297. (define_insn ""
  298.   [(set (match_operand:SI 0 "some_operand" "=&r")
  299.     (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "some_operand" "rJ")
  300.                    (match_operand:SI 2 "const48_operand" "I"))
  301.               (match_operand:SI 3 "some_operand" "r"))
  302.          (match_operand:SI 4 "some_operand" "rIOKL")))]
  303.   "reload_in_progress"
  304.   "#"
  305.   [(set_attr "type" "iaddlog")])
  306.  
  307. (define_split
  308.   [(set (match_operand:SI 0 "register_operand" "r")
  309.     (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
  310.                    (match_operand:SI 2 "const48_operand" ""))
  311.               (match_operand:SI 3 "register_operand" ""))
  312.          (match_operand:SI 4 "add_operand" "rIOKL")))]
  313.   "reload_completed"
  314.   [(set (match_dup 0)
  315.     (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  316.    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
  317.   "")
  318.  
  319. (define_insn ""
  320.   [(set (match_operand:DI 0 "some_operand" "=&r")
  321.     (sign_extend:DI
  322.      (plus:SI (plus:SI
  323.            (mult:SI (match_operand:SI 1 "some_operand" "rJ")
  324.                 (match_operand:SI 2 "const48_operand" "I"))
  325.            (match_operand:SI 3 "some_operand" "r"))
  326.           (match_operand:SI 4 "some_operand" "rIOKL"))))]
  327.   "reload_in_progress"
  328.   "#"
  329.   [(set_attr "type" "iaddlog")])
  330.  
  331. (define_split
  332.   [(set (match_operand:DI 0 "register_operand" "")
  333.     (sign_extend:DI
  334.      (plus:SI (plus:SI
  335.            (mult:SI (match_operand:SI 1 "reg_or_0_operand" "")
  336.                 (match_operand:SI 2 "const48_operand" ""))
  337.            (match_operand:SI 3 "register_operand" ""))
  338.           (match_operand:SI 4 "add_operand" ""))))]
  339.   "reload_completed"
  340.   [(set (match_dup 5)
  341.     (plus:SI (mult:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
  342.    (set (match_dup 0) (sign_extend:DI (plus:SI (match_dup 5) (match_dup 4))))]
  343.   "
  344. { operands[5] = gen_lowpart (SImode, operands[0]);
  345. }")
  346.  
  347. (define_insn ""
  348.   [(set (match_operand:DI 0 "some_operand" "=&r")
  349.     (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "some_operand" "rJ")
  350.                    (match_operand:DI 2 "const48_operand" "I"))
  351.               (match_operand:DI 3 "some_operand" "r"))
  352.          (match_operand:DI 4 "some_operand" "rIOKL")))]
  353.   "reload_in_progress"
  354.   "#"
  355.   [(set_attr "type" "iaddlog")])
  356.  
  357. (define_split
  358.   [(set (match_operand:DI 0 "register_operand" "=")
  359.     (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "")
  360.                    (match_operand:DI 2 "const48_operand" ""))
  361.               (match_operand:DI 3 "register_operand" ""))
  362.          (match_operand:DI 4 "add_operand" "")))]
  363.   "reload_completed"
  364.   [(set (match_dup 0)
  365.     (plus:DI (mult:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
  366.    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
  367.   "")
  368.  
  369. (define_insn "negsi2"
  370.   [(set (match_operand:SI 0 "register_operand" "=r")
  371.     (neg:SI (match_operand:SI 1 "reg_or_8bit_operand" "rI")))]
  372.   ""
  373.   "subl $31,%1,%0"
  374.   [(set_attr "type" "iaddlog")])
  375.  
  376. (define_insn ""
  377.   [(set (match_operand:DI 0 "register_operand" "=r")
  378.     (sign_extend:DI (neg:SI
  379.              (match_operand:SI 1 "reg_or_8bit_operand" "rI"))))]
  380.   ""
  381.   "subl $31,%1,%0"
  382.   [(set_attr "type" "iaddlog")])
  383.  
  384. (define_insn "negdi2"
  385.   [(set (match_operand:DI 0 "register_operand" "=r")
  386.     (neg:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
  387.   ""
  388.   "subq $31,%1,%0"
  389.   [(set_attr "type" "iaddlog")])
  390.  
  391. (define_expand "subsi3"
  392.   [(set (match_operand:SI 0 "register_operand" "")
  393.     (minus:SI (match_operand:SI 1 "reg_or_0_operand" "")
  394.           (match_operand:SI 2 "reg_or_8bit_operand" "")))]
  395.   ""
  396.   "
  397. { emit_insn (gen_rtx (SET, VOIDmode, gen_lowpart (DImode, operands[0]),
  398.               gen_rtx (MINUS, DImode,
  399.                    gen_lowpart (DImode, operands[1]),
  400.                    gen_lowpart (DImode, operands[2]))));
  401.   DONE;
  402.  
  403. } ")
  404.  
  405. (define_insn ""
  406.   [(set (match_operand:SI 0 "register_operand" "=r")
  407.     (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  408.           (match_operand:SI 2 "reg_or_8bit_operand" "rI")))]
  409.   ""
  410.   "subl %r1,%2,%0"
  411.   [(set_attr "type" "iaddlog")])
  412.  
  413. (define_insn ""
  414.   [(set (match_operand:DI 0 "register_operand" "=r")
  415.     (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  416.                   (match_operand:SI 2 "reg_or_8bit_operand" "rI"))))]
  417.   ""
  418.   "subl %r1,%2,%0"
  419.   [(set_attr "type" "iaddlog")])
  420.  
  421. (define_insn "subdi3"
  422.   [(set (match_operand:DI 0 "register_operand" "=r")
  423.     (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  424.           (match_operand:DI 2 "reg_or_8bit_operand" "rI")))]
  425.   ""
  426.   "subq %r1,%2,%0"
  427.   [(set_attr "type" "iaddlog")])
  428.  
  429. (define_insn ""
  430.   [(set (match_operand:SI 0 "register_operand" "=r")
  431.     (minus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  432.                (match_operand:SI 2 "const48_operand" "I"))
  433.           (match_operand:SI 3 "reg_or_8bit_operand" "rI")))]
  434.   ""
  435.   "s%2subl %r1,%3,%0"
  436.   [(set_attr "type" "iaddlog")])
  437.  
  438. (define_insn ""
  439.   [(set (match_operand:DI 0 "register_operand" "=r")
  440.     (sign_extend:DI
  441.      (minus:SI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
  442.                 (match_operand:SI 2 "const48_operand" "I"))
  443.            (match_operand:SI 3 "reg_or_8bit_operand" "rI"))))]
  444.   ""
  445.   "s%2subl %r1,%3,%0"
  446.   [(set_attr "type" "iaddlog")])
  447.  
  448. (define_insn ""
  449.   [(set (match_operand:DI 0 "register_operand" "=r")
  450.     (minus:DI (mult:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  451.                (match_operand:DI 2 "const48_operand" "I"))
  452.           (match_operand:DI 3 "reg_or_8bit_operand" "rI")))]
  453.   ""
  454.   "s%2subq %r1,%3,%0"
  455.   [(set_attr "type" "iaddlog")])
  456.  
  457. (define_insn "mulsi3"
  458.   [(set (match_operand:SI 0 "register_operand" "=r")
  459.     (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
  460.          (match_operand:SI 2 "reg_or_0_operand" "rJ")))]
  461.   ""
  462.   "mull %r1,%r2,%0"
  463.   [(set_attr "type" "imull")])
  464.  
  465. (define_insn ""
  466.   [(set (match_operand:DI 0 "register_operand" "=r")
  467.     (sign_extend:DI (mult:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
  468.                  (match_operand:SI 2 "reg_or_0_operand" "rJ"))))]
  469.   ""
  470.   "mull %r1,%r2,%0"
  471.   [(set_attr "type" "imull")])
  472.  
  473. (define_insn "muldi3"
  474.   [(set (match_operand:DI 0 "register_operand" "=r")
  475.     (mult:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
  476.          (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
  477.   ""
  478.   "mulq %r1,%r2,%0"
  479.   [(set_attr "type" "imulq")])
  480.  
  481. (define_insn "umuldi3_highpart"
  482.   [(set (match_operand:DI 0 "register_operand" "=r")
  483.     (truncate:DI
  484.      (lshiftrt:TI
  485.       (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
  486.            (zero_extend:TI (match_operand:DI 2 "register_operand" "r")))
  487.       (const_int 64))))]
  488.   ""
  489.   "umulh %1,%2,%0"
  490.   [(set_attr "type" "imulq")])
  491.  
  492. (define_insn ""
  493.   [(set (match_operand:DI 0 "register_operand" "=r")
  494.     (truncate:DI
  495.      (lshiftrt:TI
  496.       (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "r"))
  497.            (match_operand:TI 2 "cint8_operand" "I"))
  498.       (const_int 64))))]
  499.   ""
  500.   "umulh %1,%2,%0"
  501.   [(set_attr "type" "imulq")])
  502.  
  503. ;; The divide and remainder operations always take their inputs from
  504. ;; r24 and r25, put their output in r27, and clobber r23 and r28.
  505.  
  506. (define_expand "divsi3"
  507.   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
  508.    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
  509.    (parallel [(set (reg:SI 27)
  510.            (div:SI (reg:SI 24)
  511.                (reg:SI 25)))
  512.           (clobber (reg:DI 23))
  513.           (clobber (reg:DI 28))])
  514.    (set (match_operand:SI 0 "general_operand" "")
  515.     (reg:SI 27))]
  516.   ""
  517.   "")
  518.  
  519. (define_expand "udivsi3"
  520.   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
  521.    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
  522.    (parallel [(set (reg:SI 27)
  523.            (udiv:SI (reg:SI 24)
  524.                 (reg:SI 25)))
  525.           (clobber (reg:DI 23))
  526.           (clobber (reg:DI 28))])
  527.    (set (match_operand:SI 0 "general_operand" "")
  528.     (reg:SI 27))]
  529.   ""
  530.   "")
  531.  
  532. (define_expand "modsi3"
  533.   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
  534.    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
  535.    (parallel [(set (reg:SI 27)
  536.            (mod:SI (reg:SI 24)
  537.                (reg:SI 25)))
  538.           (clobber (reg:DI 23))
  539.           (clobber (reg:DI 28))])
  540.    (set (match_operand:SI 0 "general_operand" "")
  541.     (reg:SI 27))]
  542.   ""
  543.   "")
  544.  
  545. (define_expand "umodsi3"
  546.   [(set (reg:SI 24) (match_operand:SI 1 "input_operand" ""))
  547.    (set (reg:SI 25) (match_operand:SI 2 "input_operand" ""))
  548.    (parallel [(set (reg:SI 27)
  549.            (umod:SI (reg:SI 24)
  550.                 (reg:SI 25)))
  551.           (clobber (reg:DI 23))
  552.           (clobber (reg:DI 28))])
  553.    (set (match_operand:SI 0 "general_operand" "")
  554.     (reg:SI 27))]
  555.   ""
  556.   "")
  557.  
  558. (define_expand "divdi3"
  559.   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
  560.    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
  561.    (parallel [(set (reg:DI 27)
  562.            (div:DI (reg:DI 24)
  563.                (reg:DI 25)))
  564.           (clobber (reg:DI 23))
  565.           (clobber (reg:DI 28))])
  566.    (set (match_operand:DI 0 "general_operand" "")
  567.     (reg:DI 27))]
  568.   ""
  569.   "")
  570.  
  571. (define_expand "udivdi3"
  572.   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
  573.    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
  574.    (parallel [(set (reg:DI 27)
  575.            (udiv:DI (reg:DI 24)
  576.                 (reg:DI 25)))
  577.           (clobber (reg:DI 23))
  578.           (clobber (reg:DI 28))])
  579.    (set (match_operand:DI 0 "general_operand" "")
  580.     (reg:DI 27))]
  581.   ""
  582.   "")
  583.  
  584. (define_expand "moddi3"
  585.   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
  586.    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
  587.    (parallel [(set (reg:DI 27)
  588.            (mod:DI (reg:DI 24)
  589.                (reg:DI 25)))
  590.           (clobber (reg:DI 23))
  591.           (clobber (reg:DI 28))])
  592.    (set (match_operand:DI 0 "general_operand" "")
  593.     (reg:DI 27))]
  594.   ""
  595.   "")
  596.  
  597. (define_expand "umoddi3"
  598.   [(set (reg:DI 24) (match_operand:DI 1 "input_operand" ""))
  599.    (set (reg:DI 25) (match_operand:DI 2 "input_operand" ""))
  600.    (parallel [(set (reg:DI 27)
  601.            (umod:DI (reg:DI 24)
  602.                 (reg:DI 25)))
  603.           (clobber (reg:DI 23))
  604.           (clobber (reg:DI 28))])
  605.    (set (match_operand:DI 0 "general_operand" "")
  606.     (reg:DI 27))]
  607.   ""
  608.   "")
  609.  
  610. (define_insn ""
  611.   [(set (reg:SI 27)
  612.     (match_operator:SI 1 "divmod_operator"
  613.             [(reg:SI 24) (reg:SI 25)]))
  614.    (clobber (reg:DI 23))
  615.    (clobber (reg:DI 28))]
  616.   ""
  617.   "%E1 $24,$25,$27"
  618.   [(set_attr "type" "isubr")])
  619.  
  620. (define_insn ""
  621.   [(set (reg:DI 27)
  622.     (match_operator:DI 1 "divmod_operator"
  623.             [(reg:DI 24) (reg:DI 25)]))
  624.    (clobber (reg:DI 23))
  625.    (clobber (reg:DI 28))]
  626.   ""
  627.   "%E1 $24,$25,$27"
  628.   [(set_attr "type" "isubr")])
  629.  
  630. ;; Next are the basic logical operations.  These only exist in DImode.
  631.  
  632. (define_insn "anddi3"
  633.   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
  634.     (and:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ")
  635.         (match_operand:DI 2 "and_operand" "rI,N,MH")))]
  636.   ""
  637.   "@
  638.    and %r1,%2,%0
  639.    bic %r1,%N2,%0
  640.    zapnot %r1,%m2,%0"
  641.   [(set_attr "type" "iaddlog,iaddlog,shiftcm")])
  642.  
  643. ;; There are times when we can split and AND into two AND insns.  This occurs
  644. ;; when we can first clear any bytes and then clear anything else.  For
  645. ;; example "I & 0xffff07" is "(I & 0xffffff) & 0xffffffffffffff07".
  646. ;; Only to this when running on 64-bit host since the computations are
  647. ;; too messy otherwise.
  648.  
  649. (define_split
  650.   [(set (match_operand:DI 0 "register_operand" "")
  651.     (and:DI (match_operand:DI 1 "register_operand" "")
  652.         (match_operand:DI 2 "const_int_operand" "")))]
  653.   "HOST_BITS_PER_WIDE_INT == 64 && ! and_operand (operands[2], DImode)"
  654.   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
  655.    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
  656.   "
  657. {
  658.   unsigned HOST_WIDE_INT mask1 = INTVAL (operands[2]);
  659.   unsigned HOST_WIDE_INT mask2 = mask1;
  660.   int i;
  661.  
  662.   /* For each byte that isn't all zeros, make it all ones.  */
  663.   for (i = 0; i < 64; i += 8)
  664.     if ((mask1 & ((HOST_WIDE_INT) 0xff << i)) != 0)
  665.       mask1 |= (HOST_WIDE_INT) 0xff << i;
  666.  
  667.   /* Now turn on any bits we've just turned off.  */
  668.   mask2 |= ~ mask1;
  669.  
  670.   operands[3] = GEN_INT (mask1);
  671.   operands[4] = GEN_INT (mask2);
  672. }")
  673.  
  674. (define_insn "zero_extendqihi2"
  675.   [(set (match_operand:HI 0 "register_operand" "=r")
  676.     (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
  677.   ""
  678.   "zapnot %1,1,%0"
  679.   [(set_attr "type" "iaddlog")])
  680.  
  681. (define_insn "zero_extendqisi2"
  682.   [(set (match_operand:SI 0 "register_operand" "=r")
  683.     (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
  684.   ""
  685.   "zapnot %1,1,%0"
  686.   [(set_attr "type" "iaddlog")])
  687.  
  688. (define_insn "zero_extendqidi2"
  689.   [(set (match_operand:DI 0 "register_operand" "=r")
  690.     (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
  691.   ""
  692.   "zapnot %1,1,%0"
  693.   [(set_attr "type" "iaddlog")])
  694.  
  695. (define_insn "zero_extendhisi2"
  696.   [(set (match_operand:SI 0 "register_operand" "=r")
  697.     (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
  698.   ""
  699.   "zapnot %1,3,%0"
  700.   [(set_attr "type" "iaddlog")])
  701.  
  702. (define_insn "zero_extendhidi2"
  703.   [(set (match_operand:DI 0 "register_operand" "=r")
  704.     (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
  705.   ""
  706.   "zapnot %1,3,%0"
  707.   [(set_attr "type" "iaddlog")])
  708.  
  709. (define_insn "zero_extendsidi2"
  710.   [(set (match_operand:DI 0 "register_operand" "=r")
  711.     (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
  712.   ""
  713.   "zapnot %1,15,%0"
  714.   [(set_attr "type" "iaddlog")])
  715.  
  716. (define_insn  ""
  717.   [(set (match_operand:DI 0 "register_operand" "=r")
  718.     (and:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
  719.         (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
  720.   ""
  721.   "bic %r2,%1,%0"
  722.   [(set_attr "type" "iaddlog")])
  723.  
  724. (define_insn "iordi3"
  725.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  726.     (ior:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
  727.         (match_operand:DI 2 "or_operand" "rI,N")))]
  728.   ""
  729.   "@
  730.    bis %r1,%2,%0
  731.    ornot %r1,%N2,%0"
  732.   [(set_attr "type" "iaddlog")])
  733.  
  734. (define_insn "one_cmpldi2"
  735.   [(set (match_operand:DI 0 "register_operand" "=r")
  736.     (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI")))]
  737.   ""
  738.   "ornot $31,%1,%0"
  739.   [(set_attr "type" "iaddlog")])
  740.  
  741. (define_insn ""
  742.   [(set (match_operand:DI 0 "register_operand" "=r")
  743.     (ior:DI (not:DI (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
  744.         (match_operand:DI 2 "reg_or_0_operand" "rJ")))]
  745.   ""
  746.   "ornot %r2,%1,%0"
  747.   [(set_attr "type" "iaddlog")])
  748.  
  749. (define_insn "xordi3"
  750.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  751.     (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ")
  752.         (match_operand:DI 2 "or_operand" "rI,N")))]
  753.   ""
  754.   "@
  755.    xor %r1,%2,%0
  756.    eqv %r1,%N2,%0"
  757.   [(set_attr "type" "iaddlog")])
  758.  
  759. (define_insn ""
  760.   [(set (match_operand:DI 0 "register_operand" "=r")
  761.     (not:DI (xor:DI (match_operand:DI 1 "register_operand" "%rJ")
  762.             (match_operand:DI 2 "register_operand" "rI"))))]
  763.   ""
  764.   "eqv %r1,%2,%0"
  765.   [(set_attr "type" "iaddlog")])
  766.  
  767. ;; Next come the shifts and the various extract and insert operations.
  768.  
  769. (define_insn "ashldi3"
  770.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  771.     (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,rJ")
  772.            (match_operand:DI 2 "reg_or_6bit_operand" "P,rI")))]
  773.   ""
  774.   "*
  775. {
  776.   switch (which_alternative)
  777.     {
  778.     case 0:
  779.       if (operands[2] == const1_rtx)
  780.     return \"addq %r1,%r1,%0\";
  781.       else
  782.     return \"s%P2addq %r1,0,%0\";
  783.     case 1:
  784.       return \"sll %r1,%2,%0\";
  785.     }
  786. }"
  787.   [(set_attr "type" "iaddlog,shiftcm")])
  788.  
  789. ;; ??? The following pattern is made by combine, but earlier phases
  790. ;; (specifically flow) can't handle it.  This occurs in jump.c.  Deal
  791. ;; with this in a better way at some point.
  792. ;;(define_insn ""
  793. ;;  [(set (match_operand:DI 0 "register_operand" "=r")
  794. ;;    (sign_extend:DI
  795. ;;     (subreg:SI (ashift:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  796. ;;                   (match_operand:DI 2 "const_int_operand" "P"))
  797. ;;            0)))]
  798. ;;  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3"
  799. ;;  "*
  800. ;;{
  801. ;;  if (operands[2] == const1_rtx)
  802. ;;    return \"addl %r1,%r1,%0\";
  803. ;;  else
  804. ;;    return \"s%P2addl %r1,0,%0\";
  805. ;; }"
  806. ;;  [(set_attr "type" "iaddlog")])
  807.               
  808. (define_insn "lshrdi3"
  809.   [(set (match_operand:DI 0 "register_operand" "=r")
  810.     (lshiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  811.              (match_operand:DI 2 "reg_or_6bit_operand" "rI")))]
  812.   ""
  813.   "srl %r1,%2,%0")
  814.  
  815. (define_insn "ashrdi3"
  816.   [(set (match_operand:DI 0 "register_operand" "=r")
  817.     (ashiftrt:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  818.              (match_operand:DI 2 "reg_or_6bit_operand" "rI")))]
  819.   ""
  820.   "sra %r1,%2,%0")
  821.  
  822. (define_expand "extendqihi2"
  823.   [(set (match_dup 2)
  824.     (ashift:DI (match_operand:QI 1 "register_operand" "")
  825.            (const_int 56)))
  826.    (set (match_operand:HI 0 "register_operand" "")
  827.     (ashiftrt:DI (match_dup 2)
  828.              (const_int 56)))]
  829.   ""
  830.   "
  831. { operands[0] = gen_lowpart (DImode, operands[0]);
  832.   operands[1] = gen_lowpart (DImode, operands[1]);
  833.   operands[2] = gen_reg_rtx (DImode);
  834. }")
  835.  
  836. (define_expand "extendqisi2"
  837.   [(set (match_dup 2)
  838.     (ashift:DI (match_operand:QI 1 "register_operand" "")
  839.            (const_int 56)))
  840.    (set (match_operand:SI 0 "register_operand" "")
  841.     (ashiftrt:DI (match_dup 2)
  842.              (const_int 56)))]
  843.   ""
  844.   "
  845. { operands[0] = gen_lowpart (DImode, operands[0]);
  846.   operands[1] = gen_lowpart (DImode, operands[1]);
  847.   operands[2] = gen_reg_rtx (DImode);
  848. }")
  849.  
  850. (define_expand "extendqidi2"
  851.   [(set (match_dup 2)
  852.     (ashift:DI (match_operand:QI 1 "register_operand" "")
  853.            (const_int 56)))
  854.    (set (match_operand:DI 0 "register_operand" "")
  855.     (ashiftrt:DI (match_dup 2)
  856.              (const_int 56)))]
  857.   ""
  858.   "
  859. { operands[1] = gen_lowpart (DImode, operands[1]);
  860.   operands[2] = gen_reg_rtx (DImode);
  861. }")
  862.  
  863. (define_expand "extendhisi2"
  864.   [(set (match_dup 2)
  865.     (ashift:DI (match_operand:HI 1 "register_operand" "")
  866.            (const_int 48)))
  867.    (set (match_operand:SI 0 "register_operand" "")
  868.     (ashiftrt:DI (match_dup 2)
  869.              (const_int 48)))]
  870.   ""
  871.   "
  872. { operands[0] = gen_lowpart (DImode, operands[0]);
  873.   operands[1] = gen_lowpart (DImode, operands[1]);
  874.   operands[2] = gen_reg_rtx (DImode);
  875. }")
  876.  
  877. (define_expand "extendhidi2"
  878.   [(set (match_dup 2)
  879.     (ashift:DI (match_operand:HI 1 "register_operand" "")
  880.            (const_int 48)))
  881.    (set (match_operand:DI 0 "register_operand" "")
  882.     (ashiftrt:DI (match_dup 2)
  883.              (const_int 48)))]
  884.   ""
  885.   "
  886. { operands[1] = gen_lowpart (DImode, operands[1]);
  887.   operands[2] = gen_reg_rtx (DImode);
  888. }")
  889.  
  890. (define_insn ""
  891.   [(set (match_operand:DI 0 "register_operand" "=r")
  892.     (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  893.              (match_operand:DI 2 "mode_width_operand" "n")
  894.              (match_operand:DI 3 "mul8_operand" "I")))]
  895.   ""
  896.   "ext%M2l %r1,%s3,%0")
  897.  
  898. (define_insn ""
  899.   [(set (match_operand:DI 0 "register_operand" "=r")
  900.     (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  901.              (match_operand:DI 2 "mode_width_operand" "n")
  902.              (ashift:DI (match_operand:DI 3 "reg_or_8bit_operand" "rI")
  903.                     (const_int 3))))]
  904.   ""
  905.   "ext%M2l %r1,%3,%0")
  906.  
  907. (define_insn ""
  908.   [(set (match_operand:DI 0 "register_operand" "=r")
  909.     (ashift:DI
  910.      (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  911.               (const_int 8)
  912.               (ashift:DI
  913.                (plus:DI
  914.                 (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  915.                 (const_int -1))
  916.                (const_int 3)))
  917.      (const_int 56)))]
  918.   ""
  919.   "extqh %r1,%2,%0")
  920.  
  921. (define_insn ""
  922.   [(set (match_operand:DI 0 "register_operand" "=r")
  923.     (ashift:DI
  924.      (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  925.               (const_int 16)
  926.               (ashift:DI
  927.                (plus:DI
  928.                 (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  929.                 (const_int -2))
  930.                (const_int 3)))
  931.      (const_int 48)))]
  932.   ""
  933.   "extwh %r1,%2,%0")
  934.  
  935. (define_insn ""
  936.   [(set (match_operand:DI 0 "register_operand" "=r")
  937.     (ashift:DI
  938.      (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  939.               (const_int 32)
  940.               (ashift:DI
  941.                (plus:DI
  942.                 (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  943.                 (const_int -4))
  944.                (const_int 3)))
  945.      (const_int 32)))]
  946.   ""
  947.   "extlh %r1,%2,%0")
  948.  
  949. ;; This converts an extXl into an extXh with an appropriate adjustment
  950. ;; to the address calculation.
  951.  
  952. (define_split
  953.   [(set (match_operand:DI 0 "register_operand" "")
  954.     (ashift:DI (zero_extract:DI (match_operand:DI 1 "register_operand" "")
  955.                     (match_operand:DI 2 "mode_width_operand" "")
  956.                     (ashift:DI (match_operand:DI 3 "" "")
  957.                            (const_int 3)))
  958.            (match_operand:DI 4 "const_int_operand" "")))
  959.    (clobber (match_operand:DI 5 "register_operand" ""))]
  960.   "INTVAL (operands[4]) == 64 - INTVAL (operands[2])"
  961.   [(set (match_dup 5) (match_dup 6))
  962.    (set (match_dup 0)
  963.     (ashift:DI (zero_extract:DI (match_dup 1) (match_dup 2)
  964.                     (ashift:DI (plus:DI (match_dup 5)
  965.                             (match_dup 7))
  966.                            (const_int 3)))
  967.            (match_dup 4)))]
  968.   "
  969. {
  970.   operands[6] = plus_constant (operands[3], 
  971.                    INTVAL (operands[2]) / BITS_PER_UNIT);
  972.   operands[7] = GEN_INT (- INTVAL (operands[2]) / BITS_PER_UNIT);
  973. }")
  974.   
  975. (define_insn ""
  976.   [(set (match_operand:DI 0 "register_operand" "=r")
  977.     (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
  978.            (match_operand:DI 2 "mul8_operand" "I")))]
  979.   ""
  980.   "insbl %1,%s2,%0")
  981.  
  982. (define_insn ""
  983.   [(set (match_operand:DI 0 "register_operand" "=r")
  984.     (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
  985.            (match_operand:DI 2 "mul8_operand" "I")))]
  986.   ""
  987.   "inswl %1,%s2,%0")
  988.  
  989. (define_insn ""
  990.   [(set (match_operand:DI 0 "register_operand" "=r")
  991.     (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  992.            (match_operand:DI 2 "mul8_operand" "I")))]
  993.   ""
  994.   "insll %1,%s2,%0")
  995.  
  996. (define_insn ""
  997.   [(set (match_operand:DI 0 "register_operand" "=r")
  998.     (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
  999.            (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  1000.                   (const_int 3))))]
  1001.   ""
  1002.   "insbl %1,%2,%0")
  1003.  
  1004. (define_insn ""
  1005.   [(set (match_operand:DI 0 "register_operand" "=r")
  1006.     (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" "r"))
  1007.            (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  1008.                   (const_int 3))))]
  1009.   ""
  1010.   "inswl %1,%2,%0")
  1011.  
  1012. (define_insn ""
  1013.   [(set (match_operand:DI 0 "register_operand" "=r")
  1014.     (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
  1015.            (ashift:DI (match_operand:DI 2 "reg_or_8bit_operand" "rI")
  1016.                   (const_int 3))))]
  1017.   ""
  1018.   "insll %1,%2,%0")
  1019.  
  1020. ;; We do not include the insXh insns because they are complex to express
  1021. ;; and it does not appear that we would ever want to generate them.
  1022.  
  1023. (define_insn ""
  1024.   [(set (match_operand:DI 0 "register_operand" "=r")
  1025.     (and:DI (not:DI (ashift:DI
  1026.              (match_operand:DI 2 "mode_mask_operand" "n")
  1027.              (ashift:DI
  1028.               (match_operand:DI 3 "reg_or_8bit_operand" "rI")
  1029.               (const_int 3))))
  1030.         (match_operand:DI 1 "reg_or_0_operand" "rJ")))]
  1031.   ""
  1032.   "msk%U2l %r1,%3,%0")
  1033.  
  1034. ;; We do not include the mskXh insns because it does not appear we would ever
  1035. ;; generate one.
  1036.  
  1037. ;; Floating-point operations.  All the double-precision insns can extend
  1038. ;; from single, so indicate that.  The exception are the ones that simply
  1039. ;; play with the sign bits; it's not clear what to do there.
  1040.  
  1041. (define_insn "abssf2"
  1042.   [(set (match_operand:SF 0 "register_operand" "=f")
  1043.     (abs:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
  1044.   "TARGET_FP"
  1045.   "cpys $f31,%R1,%0"
  1046.   [(set_attr "type" "fpop")])
  1047.  
  1048. (define_insn "absdf2"
  1049.   [(set (match_operand:DF 0 "register_operand" "=f")
  1050.     (abs:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
  1051.   "TARGET_FP"
  1052.   "cpys $f31,%R1,%0"
  1053.   [(set_attr "type" "fpop")])
  1054.  
  1055. (define_insn "negsf2"
  1056.   [(set (match_operand:SF 0 "register_operand" "=f")
  1057.     (neg:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")))]
  1058.   "TARGET_FP"
  1059.   "cpysn %R1,%R1,%0"
  1060.   [(set_attr "type" "fpop")])
  1061.  
  1062. (define_insn "negdf2"
  1063.   [(set (match_operand:DF 0 "register_operand" "=f")
  1064.     (neg:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
  1065.   "TARGET_FP"
  1066.   "cpysn %R1,%R1,%0"
  1067.   [(set_attr "type" "fpop")])
  1068.  
  1069. (define_insn "addsf3"
  1070.   [(set (match_operand:SF 0 "register_operand" "=f")
  1071.     (plus:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
  1072.          (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
  1073.   "TARGET_FP"
  1074.   "adds %R1,%R2,%0"
  1075.   [(set_attr "type" "fpop")])
  1076.  
  1077. (define_insn "adddf3"
  1078.   [(set (match_operand:DF 0 "register_operand" "=f")
  1079.     (plus:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
  1080.          (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1081.   "TARGET_FP"
  1082.   "addt %R1,%R2,%0"
  1083.   [(set_attr "type" "fpop")])
  1084.  
  1085. (define_insn ""
  1086.   [(set (match_operand:DF 0 "register_operand" "=f")
  1087.     (plus:DF (float_extend:DF
  1088.           (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1089.          (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1090.   "TARGET_FP"
  1091.   "addt %R1,%R2,%0"
  1092.   [(set_attr "type" "fpop")])
  1093.  
  1094. (define_insn ""
  1095.   [(set (match_operand:DF 0 "register_operand" "=f")
  1096.     (plus:DF (float_extend:DF
  1097.           (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
  1098.          (float_extend:DF
  1099.           (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1100.   "TARGET_FP"
  1101.   "addt %R1,%R2,%0"
  1102.   [(set_attr "type" "fpop")])
  1103.  
  1104. (define_insn "fix_truncdfdi2"
  1105.   [(set (match_operand:DI 0 "register_operand" "=f")
  1106.     (fix:DI (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
  1107.   "TARGET_FP"
  1108.   "cvttqc %R1,%0"
  1109.   [(set_attr "type" "fpop")])
  1110.  
  1111. (define_insn "fix_truncsfdi2"
  1112.   [(set (match_operand:DI 0 "register_operand" "=f")
  1113.     (fix:DI (float_extend:DF
  1114.          (match_operand:SF 1 "reg_or_fp0_operand" "fG"))))]
  1115.   "TARGET_FP"
  1116.   "cvttqc %R1,%0"
  1117.   [(set_attr "type" "fpop")])
  1118.  
  1119. (define_insn "floatdisf2"
  1120.   [(set (match_operand:SF 0 "register_operand" "=f")
  1121.     (float:SF (match_operand:DI 1 "register_operand" "f")))]
  1122.   "TARGET_FP"
  1123.   "cvtqs %1,%0"
  1124.   [(set_attr "type" "fpop")])
  1125.  
  1126. (define_insn "floatdidf2"
  1127.   [(set (match_operand:DF 0 "register_operand" "=f")
  1128.     (float:DF (match_operand:DI 1 "register_operand" "f")))]
  1129.   "TARGET_FP"
  1130.   "cvtqt %1,%0"
  1131.   [(set_attr "type" "fpop")])
  1132.  
  1133. (define_insn "extendsfdf2"
  1134.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  1135.     (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,m")))]
  1136.   "TARGET_FP"
  1137.   "@
  1138.    addt $f31,%1,%0
  1139.    lds %0,%1"
  1140.   [(set_attr "type" "fpop,ld")])
  1141.  
  1142. (define_insn "truncdfsf2"
  1143.   [(set (match_operand:SF 0 "register_operand" "=f")
  1144.     (float_truncate:SF (match_operand:DF 1 "reg_or_fp0_operand" "fG")))]
  1145.   "TARGET_FP"
  1146.   "cvtts %R1,%0"
  1147.   [(set_attr "type" "fpop")])
  1148.  
  1149. (define_insn "divsf3"
  1150.   [(set (match_operand:SF 0 "register_operand" "=f")
  1151.     (div:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
  1152.         (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
  1153.   "TARGET_FP"
  1154.   "divs %R1,%R2,%0"
  1155.   [(set_attr "type" "fdivs")])
  1156.  
  1157. (define_insn "divdf3"
  1158.   [(set (match_operand:DF 0 "register_operand" "=f")
  1159.     (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
  1160.         (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1161.   "TARGET_FP"
  1162.   "divt %R1,%R2,%0"
  1163.   [(set_attr "type" "fdivt")])
  1164.  
  1165. (define_insn ""
  1166.   [(set (match_operand:DF 0 "register_operand" "=f")
  1167.     (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1168.         (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1169.   "TARGET_FP"
  1170.   "divt %R1,%R2,%0"
  1171.   [(set_attr "type" "fdivt")])
  1172.  
  1173. (define_insn ""
  1174.   [(set (match_operand:DF 0 "register_operand" "=f")
  1175.     (div:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
  1176.         (float_extend:DF
  1177.          (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1178.   "TARGET_FP"
  1179.   "divt %R1,%R2,%0"
  1180.   [(set_attr "type" "fdivt")])
  1181.  
  1182. (define_insn ""
  1183.   [(set (match_operand:DF 0 "register_operand" "=f")
  1184.     (div:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1185.         (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1186.   "TARGET_FP"
  1187.   "divt %R1,%R2,%0"
  1188.   [(set_attr "type" "fdivt")])
  1189.  
  1190. (define_insn "mulsf3"
  1191.   [(set (match_operand:SF 0 "register_operand" "=f")
  1192.     (mult:SF (match_operand:SF 1 "reg_or_fp0_operand" "%fG")
  1193.          (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
  1194.   "TARGET_FP"
  1195.   "muls %R1,%R2,%0"
  1196.   [(set_attr "type" "fpop")])
  1197.  
  1198. (define_insn "muldf3"
  1199.   [(set (match_operand:DF 0 "register_operand" "=f")
  1200.     (mult:DF (match_operand:DF 1 "reg_or_fp0_operand" "%fG")
  1201.          (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1202.   "TARGET_FP"
  1203.   "mult %R1,%R2,%0"
  1204.   [(set_attr "type" "fpop")])
  1205.  
  1206. (define_insn ""
  1207.   [(set (match_operand:DF 0 "register_operand" "=f")
  1208.     (mult:DF (float_extend:DF
  1209.           (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1210.          (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1211.   "TARGET_FP"
  1212.   "mult %R1,%R2,%0"
  1213.   [(set_attr "type" "fpop")])
  1214.  
  1215. (define_insn ""
  1216.   [(set (match_operand:DF 0 "register_operand" "=f")
  1217.     (mult:DF (float_extend:DF
  1218.           (match_operand:SF 1 "reg_or_fp0_operand" "%fG"))
  1219.          (float_extend:DF
  1220.           (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1221.   "TARGET_FP"
  1222.   "mult %R1,%R2,%0"
  1223.   [(set_attr "type" "fpop")])
  1224.  
  1225. (define_insn "subsf3"
  1226.   [(set (match_operand:SF 0 "register_operand" "=f")
  1227.     (minus:SF (match_operand:SF 1 "reg_or_fp0_operand" "fG")
  1228.           (match_operand:SF 2 "reg_or_fp0_operand" "fG")))]
  1229.   "TARGET_FP"
  1230.   "subs %R1,%R2,%0"
  1231.   [(set_attr "type" "fpop")])
  1232.  
  1233. (define_insn "subdf3"
  1234.   [(set (match_operand:DF 0 "register_operand" "=f")
  1235.     (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
  1236.           (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1237.   "TARGET_FP"
  1238.   "subt %R1,%R2,%0"
  1239.   [(set_attr "type" "fpop")])
  1240.  
  1241. (define_insn ""
  1242.   [(set (match_operand:DF 0 "register_operand" "=f")
  1243.     (minus:DF (float_extend:DF
  1244.            (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1245.           (match_operand:DF 2 "reg_or_fp0_operand" "fG")))]
  1246.   "TARGET_FP"
  1247.   "subt %R1,%R2,%0"
  1248.   [(set_attr "type" "fpop")])
  1249.  
  1250. (define_insn ""
  1251.   [(set (match_operand:DF 0 "register_operand" "=f")
  1252.     (minus:DF (match_operand:DF 1 "reg_or_fp0_operand" "fG")
  1253.           (float_extend:DF
  1254.            (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1255.   "TARGET_FP"
  1256.   "subt %R1,%R2,%0"
  1257.   [(set_attr "type" "fpop")])
  1258.  
  1259. (define_insn ""
  1260.   [(set (match_operand:DF 0 "register_operand" "=f")
  1261.     (minus:DF (float_extend:DF
  1262.            (match_operand:SF 1 "reg_or_fp0_operand" "fG"))
  1263.           (float_extend:DF
  1264.            (match_operand:SF 2 "reg_or_fp0_operand" "fG"))))]
  1265.   "TARGET_FP"
  1266.   "subt %R1,%R2,%0"
  1267.   [(set_attr "type" "fpop")])
  1268.  
  1269. ;; Next are all the integer comparisons, and conditional moves and branches
  1270. ;; and some of the related define_expand's and define_split's.
  1271.  
  1272. (define_insn ""
  1273.   [(set (match_operand:DI 0 "register_operand" "=r")
  1274.     (match_operator:DI 1 "alpha_comparison_operator"
  1275.                [(match_operand:DI 2 "reg_or_0_operand" "rJ")
  1276.                 (match_operand:DI 3 "reg_or_8bit_operand" "rI")]))]
  1277.   ""
  1278.   "cmp%C1 %r2,%3,%0"
  1279.   [(set_attr "type" "icmp")])
  1280.  
  1281. ;; There are three important special-case that don't fit the above pattern
  1282. ;; but which we want to handle here.
  1283.  
  1284. (define_insn ""
  1285.   [(set (match_operand:DI 0 "register_operand" "=r")
  1286.     (ne:DI (match_operand:DI 1 "register_operand" "r")
  1287.            (const_int 0)))]
  1288.   ""
  1289.   "cmpult $31,%1,%0"
  1290.   [(set_attr "type" "icmp")])
  1291.  
  1292. (define_insn ""
  1293.   [(set (match_operand:DI 0 "register_operand" "=r")
  1294.     (gt:DI (match_operand:DI 1 "register_operand" "r")
  1295.            (const_int 0)))]
  1296.   ""
  1297.   "cmplt $31,%1,%0"
  1298.   [(set_attr "type" "icmp")])
  1299.  
  1300. (define_insn ""
  1301.   [(set (match_operand:DI 0 "register_operand" "=r")
  1302.     (ge:DI (match_operand:DI 1 "register_operand" "r")
  1303.            (const_int 0)))]
  1304.   ""
  1305.   "cmple $31,%1,%0"
  1306.   [(set_attr "type" "icmp")])
  1307.  
  1308. ;; This pattern exists so conditional moves of SImode values are handled.
  1309. ;; Comparisons are still done in DImode though.
  1310.  
  1311. (define_insn ""
  1312.   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
  1313.     (if_then_else:DI
  1314.      (match_operator 2 "signed_comparison_operator"
  1315.              [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
  1316.               (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
  1317.      (match_operand:SI 1 "reg_or_8bit_operand" "rI,0,rI,0")
  1318.      (match_operand:SI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
  1319.   "operands[3] == const0_rtx || operands[4] == const0_rtx"
  1320.   "@
  1321.    cmov%C2 %r3,%1,%0
  1322.    cmov%D2 %r3,%5,%0
  1323.    cmov%c2 %r4,%1,%0
  1324.    cmov%d2 %r4,%5,%0")
  1325.  
  1326. (define_insn ""
  1327.   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r")
  1328.     (if_then_else:DI
  1329.      (match_operator 2 "signed_comparison_operator"
  1330.              [(match_operand:DI 3 "reg_or_0_operand" "rJ,rJ,J,J")
  1331.               (match_operand:DI 4 "reg_or_0_operand" "J,J,rJ,rJ")])
  1332.      (match_operand:DI 1 "reg_or_8bit_operand" "rI,0,rI,0")
  1333.      (match_operand:DI 5 "reg_or_8bit_operand" "0,rI,0,rI")))]
  1334.   "operands[3] == const0_rtx || operands[4] == const0_rtx"
  1335.   "@
  1336.    cmov%C2 %r3,%1,%0
  1337.    cmov%D2 %r3,%5,%0
  1338.    cmov%c2 %r4,%1,%0
  1339.    cmov%d2 %r4,%5,%0")
  1340.  
  1341. (define_insn ""
  1342.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  1343.     (if_then_else:DI
  1344.      (eq (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
  1345.                   (const_int 1)
  1346.                   (const_int 0))
  1347.          (const_int 0))
  1348.      (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
  1349.      (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
  1350.   ""
  1351.   "@
  1352.    cmovlbc %r2,%1,%0
  1353.    cmovlbs %r2,%3,%0")
  1354.  
  1355. (define_insn ""
  1356.   [(set (match_operand:DI 0 "register_operand" "=r,r")
  1357.     (if_then_else:DI
  1358.      (ne (zero_extract:DI (match_operand:DI 2 "reg_or_0_operand" "rJ,rJ")
  1359.                   (const_int 1)
  1360.                   (const_int 0))
  1361.          (const_int 0))
  1362.      (match_operand:DI 1 "reg_or_8bit_operand" "rI,0")
  1363.      (match_operand:DI 3 "reg_or_8bit_operand" "0,rI")))]
  1364.   ""
  1365.   "@
  1366.    cmovlbs %r2,%1,%0
  1367.    cmovlbc %r2,%3,%0")
  1368.  
  1369. ;; This form is added since combine thinks that an IF_THEN_ELSE with both
  1370. ;; arms constant is a single insn, so it won't try to form it if combine
  1371. ;; knows they are really two insns.  This occurs in divides by powers
  1372. ;; of two.
  1373.  
  1374. (define_insn ""
  1375.   [(set (match_operand:DI 0 "register_operand" "=r")
  1376.     (if_then_else:DI
  1377.      (match_operator 2 "signed_comparison_operator"
  1378.              [(match_operand:DI 3 "reg_or_0_operand" "rJ")
  1379.               (const_int 0)])
  1380.      (plus:DI (match_dup 0)
  1381.           (match_operand:DI 1 "reg_or_8bit_operand" "rI"))
  1382.      (match_dup 0)))
  1383.    (clobber (match_scratch:DI 4 "=&r"))]
  1384.   ""
  1385.   "addq %0,%1,%4\;cmov%C2 %r3,%4,%0")
  1386.  
  1387. (define_split
  1388.   [(set (match_operand:DI 0 "register_operand" "")
  1389.     (if_then_else:DI
  1390.      (match_operator 2 "signed_comparison_operator"
  1391.              [(match_operand:DI 3 "reg_or_0_operand" "")
  1392.               (const_int 0)])
  1393.      (plus:DI (match_dup 0)
  1394.           (match_operand:DI 1 "reg_or_8bit_operand" ""))
  1395.      (match_dup 0)))
  1396.    (clobber (match_operand:DI 4 "register_operand" ""))]
  1397.   ""
  1398.   [(set (match_dup 4) (plus:DI (match_dup 0) (match_dup 1)))
  1399.    (set (match_dup 0) (if_then_else:DI (match_op_dup 2
  1400.                              [(match_dup 3)
  1401.                               (const_int 0)])
  1402.                        (match_dup 4) (match_dup 0)))]
  1403.   "")
  1404.  
  1405. (define_split
  1406.   [(parallel
  1407.     [(set (match_operand:DI 0 "register_operand" "")
  1408.       (if_then_else:DI
  1409.        (match_operator 1 "comparison_operator"
  1410.                [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
  1411.                          (const_int 1)
  1412.                          (match_operand:DI 3 "const_int_operand" ""))
  1413.                 (const_int 0)])
  1414.        (match_operand:DI 4 "reg_or_8bit_operand" "")
  1415.        (match_operand:DI 5 "reg_or_8bit_operand" "")))
  1416.      (clobber (match_operand:DI 6 "register_operand" ""))])]
  1417.   "INTVAL (operands[3]) != 0"
  1418.   [(set (match_dup 6)
  1419.     (lshiftrt:DI (match_dup 2) (match_dup 3)))
  1420.    (set (match_dup 0)
  1421.     (if_then_else:DI (match_op_dup 1
  1422.                        [(zero_extract:DI (match_dup 6)
  1423.                              (const_int 1)
  1424.                              (const_int 0))
  1425.                     (const_int 0)])
  1426.              (match_dup 4)
  1427.              (match_dup 5)))]
  1428.   "")
  1429.  
  1430. ;; For ABS, we have two choices, depending on whether the input and output
  1431. ;; registers are the same or not.
  1432. (define_expand "absdi2"
  1433.   [(set (match_operand:DI 0 "register_operand" "")
  1434.     (abs:DI (match_operand:DI 1 "register_operand" "")))]
  1435.   ""
  1436.   "
  1437. { if (rtx_equal_p (operands[0], operands[1]))
  1438.     emit_insn (gen_absdi2_same (operands[0], gen_reg_rtx (DImode)));
  1439.   else
  1440.     emit_insn (gen_absdi2_diff (operands[0], operands[1]));
  1441.  
  1442.   DONE;
  1443. }")
  1444.  
  1445. (define_expand "absdi2_same"
  1446.   [(set (match_operand:DI 1 "register_operand" "")
  1447.     (neg:DI (match_operand:DI 0 "register_operand" "")))
  1448.    (set (match_dup 0)
  1449.     (if_then_else:DI (ge (match_dup 0) (const_int 0))
  1450.              (match_dup 0)
  1451.              (match_dup 1)))]
  1452.   ""
  1453.   "")
  1454.  
  1455. (define_expand "absdi2_diff"
  1456.   [(set (match_operand:DI 0 "register_operand" "")
  1457.     (neg:DI (match_operand:DI 1 "register_operand" "")))
  1458.    (set (match_dup 0)
  1459.     (if_then_else:DI (lt (match_dup 1) (const_int 0))
  1460.              (match_dup 0)
  1461.              (match_dup 1)))]
  1462.   ""
  1463.   "")
  1464.  
  1465. (define_split
  1466.   [(set (match_operand:DI 0 "register_operand" "")
  1467.     (abs:DI (match_dup 0)))
  1468.    (clobber (match_operand:DI 2 "register_operand" ""))]
  1469.   ""
  1470.   [(set (match_dup 1) (neg:DI (match_dup 0)))
  1471.    (set (match_dup 0) (if_then_else:DI (ge (match_dup 0) (const_int 0))
  1472.                        (match_dup 0) (match_dup 1)))]
  1473.   "")
  1474.  
  1475. (define_split
  1476.   [(set (match_operand:DI 0 "register_operand" "")
  1477.     (abs:DI (match_operand:DI 1 "register_operand" "")))]
  1478.   "! rtx_equal_p (operands[0], operands[1])"
  1479.   [(set (match_dup 0) (neg:DI (match_dup 1)))
  1480.    (set (match_dup 0) (if_then_else:DI (lt (match_dup 1) (const_int 0))
  1481.                        (match_dup 0) (match_dup 1)))]
  1482.   "")
  1483.  
  1484. (define_split
  1485.   [(set (match_operand:DI 0 "register_operand" "")
  1486.     (neg:DI (abs:DI (match_dup 0))))
  1487.    (clobber (match_operand:DI 2 "register_operand" ""))]
  1488.   ""
  1489.   [(set (match_dup 1) (neg:DI (match_dup 0)))
  1490.    (set (match_dup 0) (if_then_else:DI (le (match_dup 0) (const_int 0))
  1491.                        (match_dup 0) (match_dup 1)))]
  1492.   "")
  1493.  
  1494. (define_split
  1495.   [(set (match_operand:DI 0 "register_operand" "")
  1496.     (neg:DI (abs:DI (match_operand:DI 1 "register_operand" ""))))]
  1497.   "! rtx_equal_p (operands[0], operands[1])"
  1498.   [(set (match_dup 0) (neg:DI (match_dup 1)))
  1499.    (set (match_dup 0) (if_then_else:DI (gt (match_dup 1) (const_int 0))
  1500.                        (match_dup 0) (match_dup 1)))]
  1501.   "")
  1502.  
  1503. (define_expand "smaxdi3"
  1504.   [(set (match_dup 3)
  1505.     (le:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1506.            (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1507.    (set (match_operand:DI 0 "register_operand" "")
  1508.     (if_then_else:DI (eq (match_dup 3) (const_int 0))
  1509.              (match_dup 1) (match_dup 2)))]
  1510.   ""
  1511.   "
  1512. { operands[3] = gen_reg_rtx (DImode);
  1513. }")
  1514.  
  1515. (define_split
  1516.   [(set (match_operand:DI 0 "register_operand" "")
  1517.     (smax:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1518.          (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1519.    (clobber (match_operand:DI 3 "register_operand" ""))]
  1520.   "operands[2] != const0_rtx"
  1521.   [(set (match_dup 3) (le:DI (match_dup 1) (match_dup 2)))
  1522.    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
  1523.                        (match_dup 1) (match_dup 2)))]
  1524.   "")
  1525.  
  1526. (define_insn ""
  1527.   [(set (match_operand:DI 0 "register_operand" "=r")
  1528.     (smax:DI (match_operand:DI 1 "register_operand" "0")
  1529.          (const_int 0)))]
  1530.   ""
  1531.   "cmovlt %0,0,%0")
  1532.  
  1533. (define_expand "smindi3"
  1534.   [(set (match_dup 3)
  1535.     (lt:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1536.            (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1537.    (set (match_operand:DI 0 "register_operand" "")
  1538.     (if_then_else:DI (ne (match_dup 3) (const_int 0))
  1539.              (match_dup 1) (match_dup 2)))]
  1540.   ""
  1541.   "
  1542. { operands[3] = gen_reg_rtx (DImode);
  1543. }")
  1544.  
  1545. (define_split
  1546.   [(set (match_operand:DI 0 "register_operand" "")
  1547.     (smin:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1548.          (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1549.    (clobber (match_operand:DI 3 "register_operand" ""))]
  1550.   "operands[2] != const0_rtx"
  1551.   [(set (match_dup 3) (lt:DI (match_dup 1) (match_dup 2)))
  1552.    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
  1553.                        (match_dup 1) (match_dup 2)))]
  1554.   "")
  1555.  
  1556. (define_insn ""
  1557.   [(set (match_operand:DI 0 "register_operand" "=r")
  1558.     (smin:DI (match_operand:DI 1 "register_operand" "0")
  1559.          (const_int 0)))]
  1560.   ""
  1561.   "cmovgt %0,0,%0")
  1562.  
  1563. (define_expand "umaxdi3"
  1564.   [(set (match_dup 3) 
  1565.     (leu:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1566.         (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1567.    (set (match_operand:DI 0 "register_operand" "")
  1568.     (if_then_else:DI (eq (match_dup 3) (const_int 0))
  1569.              (match_dup 1) (match_dup 2)))]
  1570.   ""
  1571.   "
  1572. { operands[3] = gen_reg_rtx (DImode);
  1573. }")
  1574.  
  1575. (define_split
  1576.   [(set (match_operand:DI 0 "register_operand" "")
  1577.     (umax:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1578.          (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1579.    (clobber (match_operand:DI 3 "register_operand" ""))]
  1580.   "operands[2] != const0_rtx"
  1581.   [(set (match_dup 3) (leu:DI (match_dup 1) (match_dup 2)))
  1582.    (set (match_dup 0) (if_then_else:DI (eq (match_dup 3) (const_int 0))
  1583.                        (match_dup 1) (match_dup 2)))]
  1584.   "")
  1585.  
  1586. (define_expand "umindi3"
  1587.   [(set (match_dup 3)
  1588.     (ltu:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1589.         (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1590.    (set (match_operand:DI 0 "register_operand" "")
  1591.     (if_then_else:DI (ne (match_dup 3) (const_int 0))
  1592.              (match_dup 1) (match_dup 2)))]
  1593.   ""
  1594.   "
  1595. { operands[3] = gen_reg_rtx (DImode);
  1596. }")
  1597.  
  1598. (define_split
  1599.   [(set (match_operand:DI 0 "register_operand" "")
  1600.     (umin:DI (match_operand:DI 1 "reg_or_0_operand" "")
  1601.          (match_operand:DI 2 "reg_or_8bit_operand" "")))
  1602.    (clobber (match_operand:DI 3 "register_operand" ""))]
  1603.   "operands[2] != const0_rtx"
  1604.   [(set (match_dup 3) (ltu:DI (match_dup 1) (match_dup 2)))
  1605.    (set (match_dup 0) (if_then_else:DI (ne (match_dup 3) (const_int 0))
  1606.                        (match_dup 1) (match_dup 2)))]
  1607.   "")
  1608.  
  1609. (define_insn ""
  1610.   [(set (pc)
  1611.     (if_then_else
  1612.      (match_operator 1 "signed_comparison_operator"
  1613.              [(match_operand:DI 2 "reg_or_0_operand" "rJ")
  1614.               (const_int 0)])
  1615.      (label_ref (match_operand 0 "" ""))
  1616.      (pc)))]
  1617.   ""
  1618.   "b%C1 %r2,%0"
  1619.   [(set_attr "type" "ibr")])
  1620.  
  1621. (define_insn ""
  1622.   [(set (pc)
  1623.     (if_then_else
  1624.      (ne (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  1625.                   (const_int 1)
  1626.                   (const_int 0))
  1627.          (const_int 0))
  1628.      (label_ref (match_operand 0 "" ""))
  1629.      (pc)))]
  1630.   ""
  1631.   "blbs %r1,%0"
  1632.   [(set_attr "type" "ibr")])
  1633.  
  1634. (define_insn ""
  1635.   [(set (pc)
  1636.     (if_then_else
  1637.      (eq (zero_extract:DI (match_operand:DI 1 "reg_or_0_operand" "rJ")
  1638.                   (const_int 1)
  1639.                   (const_int 0))
  1640.          (const_int 0))
  1641.      (label_ref (match_operand 0 "" ""))
  1642.      (pc)))]
  1643.   ""
  1644.   "blbc %r1,%0"
  1645.   [(set_attr "type" "ibr")])
  1646.  
  1647. (define_split
  1648.   [(parallel
  1649.     [(set (pc)
  1650.       (if_then_else
  1651.        (match_operator 1 "comparison_operator"
  1652.                [(zero_extract:DI (match_operand:DI 2 "register_operand" "")
  1653.                          (const_int 1)
  1654.                          (match_operand:DI 3 "const_int_operand" ""))
  1655.                 (const_int 0)])
  1656.        (label_ref (match_operand 0 "" ""))
  1657.        (pc)))
  1658.      (clobber (match_operand:DI 4 "register_operand" ""))])]
  1659.   "INTVAL (operands[3]) != 0"
  1660.   [(set (match_dup 4)
  1661.     (lshiftrt:DI (match_dup 2) (match_dup 3)))
  1662.    (set (pc)
  1663.     (if_then_else (match_op_dup 1
  1664.                     [(zero_extract:DI (match_dup 4)
  1665.                               (const_int 1)
  1666.                               (const_int 0))
  1667.                      (const_int 0)])
  1668.               (label_ref (match_dup 0))
  1669.               (pc)))]
  1670.   "")
  1671.  
  1672. ;; The following are the corresponding floating-point insns.  Recall
  1673. ;; we need to have variants that expand the arguments from SF mode
  1674. ;; to DFmode.
  1675.  
  1676. (define_insn ""
  1677.   [(set (match_operand:DF 0 "register_operand" "=f")
  1678.     (match_operator:DF 1 "alpha_comparison_operator"
  1679.                [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
  1680.                 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
  1681.   "TARGET_FP"
  1682.   "cmpt%C1 %R2,%R3,%0"
  1683.   [(set_attr "type" "fpop")])
  1684.  
  1685. (define_insn ""
  1686.   [(set (match_operand:DF 0 "register_operand" "=f")
  1687.     (match_operator:DF 1 "alpha_comparison_operator"
  1688.                [(float_extend:DF
  1689.                  (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
  1690.                 (match_operand:DF 3 "reg_or_fp0_operand" "fG")]))]
  1691.   "TARGET_FP"
  1692.   "cmpt%C1 %R2,%R3,%0"
  1693.   [(set_attr "type" "fpop")])
  1694.  
  1695. (define_insn ""
  1696.   [(set (match_operand:DF 0 "register_operand" "=f")
  1697.     (match_operator:DF 1 "alpha_comparison_operator"
  1698.                [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
  1699.                 (float_extend:DF
  1700.                  (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
  1701.   "TARGET_FP"
  1702.   "cmpt%C1 %R2,%R3,%0"
  1703.   [(set_attr "type" "fpop")])
  1704.  
  1705. (define_insn ""
  1706.   [(set (match_operand:DF 0 "register_operand" "=f")
  1707.     (match_operator:DF 1 "alpha_comparison_operator"
  1708.                [(float_extend:DF
  1709.                  (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
  1710.                 (float_extend:DF
  1711.                  (match_operand:SF 3 "reg_or_fp0_operand" "fG"))]))]
  1712.   "TARGET_FP"
  1713.   "cmpt%C1 %R2,%R3,%0"
  1714.   [(set_attr "type" "fpop")])
  1715.  
  1716. (define_insn ""
  1717.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  1718.     (if_then_else:DF 
  1719.      (match_operator 3 "signed_comparison_operator"
  1720.              [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
  1721.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1722.      (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
  1723.      (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
  1724.   "TARGET_FP"
  1725.   "@
  1726.    fcmov%C3 %R4,%R1,%0
  1727.    fcmov%D3 %R4,%R5,%0"
  1728.   [(set_attr "type" "fpop")])
  1729.  
  1730. (define_insn ""
  1731.   [(set (match_operand:SF 0 "register_operand" "=f,f")
  1732.     (if_then_else:SF 
  1733.      (match_operator 3 "signed_comparison_operator"
  1734.              [(match_operand:DF 4 "reg_or_fp0_operand" "fG,fG")
  1735.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1736.      (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
  1737.      (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
  1738.   "TARGET_FP"
  1739.   "@
  1740.    fcmov%C3 %R4,%R1,%0
  1741.    fcmov%D3 %R4,%R5,%0"
  1742.   [(set_attr "type" "fpop")])
  1743.  
  1744. (define_insn ""
  1745.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  1746.     (if_then_else:DF 
  1747.      (match_operator 3 "signed_comparison_operator"
  1748.              [(match_operand:DF 1 "reg_or_fp0_operand" "fG,fG")
  1749.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1750.      (float_extend:DF (match_operand:SF 4 "reg_or_fp0_operand" "fG,0"))
  1751.      (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
  1752.   "TARGET_FP"
  1753.   "@
  1754.    fcmov%C3 %R4,%R1,%0
  1755.    fcmov%D3 %R4,%R5,%0"
  1756.   [(set_attr "type" "fpop")])
  1757.  
  1758. (define_insn ""
  1759.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  1760.     (if_then_else:DF 
  1761.      (match_operator 3 "signed_comparison_operator"
  1762.              [(float_extend:DF 
  1763.                (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
  1764.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1765.      (match_operand:DF 1 "reg_or_fp0_operand" "fG,0")
  1766.      (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
  1767.   "TARGET_FP"
  1768.   "@
  1769.    fcmov%C3 %R4,%R1,%0
  1770.    fcmov%D3 %R4,%R5,%0"
  1771.   [(set_attr "type" "fpop")])
  1772.  
  1773. (define_insn ""
  1774.   [(set (match_operand:SF 0 "register_operand" "=f,f")
  1775.     (if_then_else:SF 
  1776.      (match_operator 3 "signed_comparison_operator"
  1777.              [(float_extend:DF
  1778.                (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
  1779.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1780.      (match_operand:SF 1 "reg_or_fp0_operand" "fG,0")
  1781.      (match_operand:SF 5 "reg_or_fp0_operand" "0,fG")))]
  1782.   "TARGET_FP"
  1783.   "@
  1784.    fcmov%C3 %R4,%R1,%0
  1785.    fcmov%D3 %R4,%R5,%0"
  1786.   [(set_attr "type" "fpop")])
  1787.  
  1788. (define_insn ""
  1789.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  1790.     (if_then_else:DF 
  1791.      (match_operator 3 "signed_comparison_operator"
  1792.              [(float_extend:DF
  1793.                (match_operand:SF 4 "reg_or_fp0_operand" "fG,fG"))
  1794.               (match_operand:DF 2 "fp0_operand" "G,G")])
  1795.      (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" "fG,0"))
  1796.      (match_operand:DF 5 "reg_or_fp0_operand" "0,fG")))]
  1797.   "TARGET_FP"
  1798.   "@
  1799.    fcmov%C3 %R4,%R1,%0
  1800.    fcmov%D3 %R4,%R5,%0"
  1801.   [(set_attr "type" "fpop")])
  1802.  
  1803. (define_expand "maxdf3"
  1804.   [(set (match_dup 3)
  1805.     (le:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
  1806.            (match_operand:DF 2 "reg_or_fp0_operand" "")))
  1807.    (set (match_operand:DF 0 "register_operand" "")
  1808.     (if_then_else:DF (eq (match_dup 3) (match_dup 4))
  1809.              (match_dup 1) (match_dup 2)))]
  1810.   "TARGET_FP"
  1811.   "
  1812. { operands[3] = gen_reg_rtx (DFmode);
  1813.   operands[4] = CONST0_RTX (DFmode);
  1814. }")
  1815.  
  1816. (define_expand "mindf3"
  1817.   [(set (match_dup 3)
  1818.     (lt:DF (match_operand:DF 1 "reg_or_fp0_operand" "")
  1819.            (match_operand:DF 2 "reg_or_fp0_operand" "")))
  1820.    (set (match_operand:DF 0 "register_operand" "")
  1821.     (if_then_else:DF (ne (match_dup 3) (match_dup 4))
  1822.              (match_dup 1) (match_dup 2)))]
  1823.   "TARGET_FP"
  1824.   "
  1825. { operands[3] = gen_reg_rtx (DFmode);
  1826.   operands[4] = CONST0_RTX (DFmode);
  1827. }")
  1828.  
  1829. (define_expand "maxsf3"
  1830.   [(set (match_dup 3)
  1831.     (le:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
  1832.            (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
  1833.    (set (match_operand:SF 0 "register_operand" "")
  1834.     (if_then_else:SF (eq (match_dup 3) (match_dup 4))
  1835.              (match_dup 1) (match_dup 2)))]
  1836.   "TARGET_FP"
  1837.   "
  1838. { operands[3] = gen_reg_rtx (DFmode);
  1839.   operands[4] = CONST0_RTX (DFmode);
  1840. }")
  1841.  
  1842. (define_expand "minsf3"
  1843.   [(set (match_dup 3)
  1844.     (lt:DF (float_extend:DF (match_operand:SF 1 "reg_or_fp0_operand" ""))
  1845.            (float_extend:DF (match_operand:SF 2 "reg_or_fp0_operand" ""))))
  1846.    (set (match_operand:SF 0 "register_operand" "")
  1847.     (if_then_else:SF (ne (match_dup 3) (match_dup 4))
  1848.               (match_dup 1) (match_dup 2)))]
  1849.   "TARGET_FP"
  1850.   "
  1851. { operands[3] = gen_reg_rtx (DFmode);
  1852.   operands[4] = CONST0_RTX (DFmode);
  1853. }")
  1854.  
  1855. (define_insn ""
  1856.   [(set (pc)
  1857.     (if_then_else
  1858.      (match_operator 1 "signed_comparison_operator"
  1859.              [(match_operand:DF 2 "reg_or_fp0_operand" "fG")
  1860.               (match_operand:DF 3 "fp0_operand" "G")])
  1861.      (label_ref (match_operand 0 "" ""))
  1862.      (pc)))]
  1863.   "TARGET_FP"
  1864.   "fb%C1 %R2,%0"
  1865.   [(set_attr "type" "fbr")])
  1866.  
  1867. (define_insn ""
  1868.   [(set (pc)
  1869.     (if_then_else
  1870.      (match_operator 1 "signed_comparison_operator"
  1871.              [(float_extend:DF
  1872.                (match_operand:SF 2 "reg_or_fp0_operand" "fG"))
  1873.               (match_operand:DF 3 "fp0_operand" "G")])
  1874.      (label_ref (match_operand 0 "" ""))
  1875.      (pc)))]
  1876.   "TARGET_FP"
  1877.   "fb%C1 %R2,%0"
  1878.   [(set_attr "type" "fbr")])
  1879.  
  1880. ;; These are the main define_expand's used to make conditional branches
  1881. ;; and compares.
  1882.  
  1883. (define_expand "cmpdf"
  1884.   [(set (cc0) (compare (match_operand:DF 0 "reg_or_fp0_operand" "")
  1885.                (match_operand:DF 1 "reg_or_fp0_operand" "")))]
  1886.   ""
  1887.   "
  1888. {
  1889.   alpha_compare_op0 = operands[0];
  1890.   alpha_compare_op1 = operands[1];
  1891.   alpha_compare_fp_p = 1;
  1892.   DONE;
  1893. }")
  1894.  
  1895. (define_expand "cmpdi"
  1896.   [(set (cc0) (compare (match_operand:DI 0 "reg_or_0_operand" "")
  1897.                (match_operand:DI 1 "reg_or_8bit_operand" "")))]
  1898.   ""
  1899.   "
  1900. {
  1901.   alpha_compare_op0 = operands[0];
  1902.   alpha_compare_op1 = operands[1];
  1903.   alpha_compare_fp_p = 0;
  1904.   DONE;
  1905. }")
  1906.  
  1907. (define_expand "beq"
  1908.   [(set (match_dup 1) (match_dup 2))
  1909.    (set (pc)
  1910.     (if_then_else (match_dup 3)
  1911.               (label_ref (match_operand 0 "" ""))
  1912.               (pc)))]
  1913.   ""
  1914.   "
  1915. {
  1916.   enum machine_mode mode;
  1917.   enum rtx_code compare_code, branch_code;
  1918.  
  1919.   if (alpha_compare_fp_p)
  1920.     mode = DFmode, compare_code = EQ, branch_code = NE;
  1921.   else
  1922.     {
  1923.       mode = DImode, compare_code = MINUS, branch_code = EQ;
  1924.       if (GET_CODE (alpha_compare_op1) == CONST_INT)
  1925.     {
  1926.       compare_code = PLUS;
  1927.       alpha_compare_op1 = GEN_INT (- INTVAL (alpha_compare_op1));
  1928.     }
  1929.     }
  1930.  
  1931.   operands[1] = gen_reg_rtx (mode);
  1932.   operands[2] = gen_rtx (compare_code, mode,
  1933.              alpha_compare_op0, alpha_compare_op1);
  1934.   operands[3] = gen_rtx (branch_code, VOIDmode,
  1935.              operands[1], CONST0_RTX (mode));
  1936. }")
  1937.  
  1938. (define_expand "bne"
  1939.   [(set (match_dup 1) (match_dup 2))
  1940.    (set (pc)
  1941.     (if_then_else (match_dup 3)
  1942.               (label_ref (match_operand 0 "" ""))
  1943.               (pc)))]
  1944.   ""
  1945.   "
  1946. {
  1947.   enum machine_mode mode;
  1948.   enum rtx_code compare_code, branch_code;
  1949.  
  1950.   if (alpha_compare_fp_p)
  1951.     mode = DFmode, compare_code = EQ, branch_code = EQ;
  1952.   else
  1953.     {
  1954.       mode = DImode, compare_code = MINUS, branch_code = NE;
  1955.       if (GET_CODE (alpha_compare_op1) == CONST_INT)
  1956.     {
  1957.       compare_code = PLUS;
  1958.       alpha_compare_op1 = GEN_INT (- INTVAL (alpha_compare_op1));
  1959.     }
  1960.     }
  1961.  
  1962.   operands[1] = gen_reg_rtx (mode);
  1963.   operands[2] = gen_rtx (compare_code, mode,
  1964.              alpha_compare_op0, alpha_compare_op1);
  1965.   operands[3] = gen_rtx (branch_code, VOIDmode,
  1966.              operands[1], CONST0_RTX (mode));
  1967. }")
  1968.  
  1969. (define_expand "blt"
  1970.   [(set (match_dup 1) (match_dup 2))
  1971.    (set (pc)
  1972.     (if_then_else (match_dup 3)
  1973.               (label_ref (match_operand 0 "" ""))
  1974.               (pc)))]
  1975.   ""
  1976.   "
  1977. {
  1978.   enum machine_mode mode = alpha_compare_fp_p ? DFmode : DImode;
  1979.   operands[1] = gen_reg_rtx (mode);
  1980.   operands[2] = gen_rtx (LT, mode, alpha_compare_op0, alpha_compare_op1);
  1981.   operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (mode));
  1982. }")
  1983.  
  1984. (define_expand "ble"
  1985.   [(set (match_dup 1) (match_dup 2))
  1986.    (set (pc)
  1987.     (if_then_else (match_dup 3)
  1988.               (label_ref (match_operand 0 "" ""))
  1989.               (pc)))]
  1990.   ""
  1991.   "
  1992. {
  1993.   enum machine_mode mode = alpha_compare_fp_p ? DFmode : DImode;
  1994.   operands[1] = gen_reg_rtx (mode);
  1995.   operands[2] = gen_rtx (LE, mode, alpha_compare_op0, alpha_compare_op1);
  1996.   operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (mode));
  1997. }")
  1998.  
  1999. (define_expand "bgt"
  2000.   [(set (match_dup 1) (match_dup 2))
  2001.    (set (pc)
  2002.     (if_then_else (match_dup 3)
  2003.               (label_ref (match_operand 0 "" ""))
  2004.               (pc)))]
  2005.   ""
  2006.   "
  2007. {
  2008.   if (alpha_compare_fp_p)
  2009.     {
  2010.       operands[1] = gen_reg_rtx (DFmode);
  2011.       operands[2] = gen_rtx (LT, DFmode, alpha_compare_op1, alpha_compare_op0);
  2012.       operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (DFmode));
  2013.     }
  2014.   else
  2015.     {
  2016.       operands[1] = gen_reg_rtx (DImode);
  2017.       operands[2] = gen_rtx (LE, DImode, alpha_compare_op0, alpha_compare_op1);
  2018.       operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
  2019.     }
  2020. }")
  2021.  
  2022. (define_expand "bge"
  2023.   [(set (match_dup 1) (match_dup 2))
  2024.    (set (pc)
  2025.     (if_then_else (match_dup 3)
  2026.               (label_ref (match_operand 0 "" ""))
  2027.               (pc)))]
  2028.   ""
  2029.   "
  2030. {
  2031.   if (alpha_compare_fp_p)
  2032.     {
  2033.       operands[1] = gen_reg_rtx (DFmode);
  2034.       operands[2] = gen_rtx (LE, DFmode, alpha_compare_op1, alpha_compare_op0);
  2035.       operands[3] = gen_rtx (NE, VOIDmode, operands[1], CONST0_RTX (DFmode));
  2036.     }
  2037.   else
  2038.     {
  2039.       operands[1] = gen_reg_rtx (DImode);
  2040.       operands[2] = gen_rtx (LT, DImode, alpha_compare_op0, alpha_compare_op1);
  2041.       operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
  2042.     }
  2043. }")
  2044.  
  2045. (define_expand "bltu"
  2046.   [(set (match_dup 1) (match_dup 2))
  2047.    (set (pc)
  2048.     (if_then_else (match_dup 3)
  2049.               (label_ref (match_operand 0 "" ""))
  2050.               (pc)))]
  2051.   ""
  2052.   "
  2053. {
  2054.   operands[1] = gen_reg_rtx (DImode);
  2055.   operands[2] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
  2056.   operands[3] = gen_rtx (NE, VOIDmode, operands[1], const0_rtx);
  2057. }")
  2058.  
  2059. (define_expand "bleu"
  2060.   [(set (match_dup 1) (match_dup 2))
  2061.    (set (pc)
  2062.     (if_then_else (match_dup 3)
  2063.               (label_ref (match_operand 0 "" ""))
  2064.               (pc)))]
  2065.   ""
  2066.   "
  2067. {
  2068.   operands[1] = gen_reg_rtx (DImode);
  2069.   operands[2] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
  2070.   operands[3] = gen_rtx (NE, VOIDmode, operands[1], const0_rtx);
  2071. }")
  2072.  
  2073. (define_expand "bgtu"
  2074.   [(set (match_dup 1) (match_dup 2))
  2075.    (set (pc)
  2076.     (if_then_else (match_dup 3)
  2077.               (label_ref (match_operand 0 "" ""))
  2078.               (pc)))]
  2079.   ""
  2080.   "
  2081. {
  2082.   operands[1] = gen_reg_rtx (DImode);
  2083.   operands[2] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
  2084.   operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
  2085. }")
  2086.  
  2087. (define_expand "bgeu"
  2088.   [(set (match_dup 1) (match_dup 2))
  2089.    (set (pc)
  2090.     (if_then_else (match_dup 3)
  2091.               (label_ref (match_operand 0 "" ""))
  2092.               (pc)))]
  2093.   ""
  2094.   "
  2095. {
  2096.   operands[1] = gen_reg_rtx (DImode);
  2097.   operands[2] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
  2098.   operands[3] = gen_rtx (EQ, VOIDmode, operands[1], const0_rtx);
  2099. }")
  2100.  
  2101. (define_expand "seq"
  2102.   [(set (match_operand:DI 0 "register_operand" "")
  2103.     (match_dup 1))]
  2104.   ""
  2105.   "
  2106. {
  2107.   if (alpha_compare_fp_p)
  2108.     FAIL;
  2109.  
  2110.   operands[1] = gen_rtx (EQ, DImode, alpha_compare_op0, alpha_compare_op1);
  2111. }")
  2112.  
  2113. (define_expand "sne"
  2114.   [(set (match_operand:DI 0 "register_operand" "")
  2115.     (match_dup 1))
  2116.    (set (match_dup 0) (xor:DI (match_dup 0) (const_int 1)))]
  2117.   ""
  2118.   "
  2119. {
  2120.   if (alpha_compare_fp_p)
  2121.     FAIL;
  2122.  
  2123.   operands[1] = gen_rtx (EQ, DImode, alpha_compare_op0, alpha_compare_op1);
  2124. }")
  2125.  
  2126. (define_expand "slt"
  2127.   [(set (match_operand:DI 0 "register_operand" "")
  2128.     (match_dup 1))]
  2129.   ""
  2130.   "
  2131. {
  2132.   if (alpha_compare_fp_p)
  2133.     FAIL;
  2134.  
  2135.   operands[1] = gen_rtx (LT, DImode, alpha_compare_op0, alpha_compare_op1);
  2136. }")
  2137.  
  2138. (define_expand "sle"
  2139.   [(set (match_operand:DI 0 "register_operand" "")
  2140.     (match_dup 1))]
  2141.   ""
  2142.   "
  2143. {
  2144.   if (alpha_compare_fp_p)
  2145.     FAIL;
  2146.  
  2147.   operands[1] = gen_rtx (LE, DImode, alpha_compare_op0, alpha_compare_op1);
  2148. }")
  2149.  
  2150. (define_expand "sgt"
  2151.   [(set (match_operand:DI 0 "register_operand" "")
  2152.     (match_dup 1))]
  2153.   ""
  2154.   "
  2155. {
  2156.   if (alpha_compare_fp_p)
  2157.     FAIL;
  2158.  
  2159.   operands[1] = gen_rtx (LT, DImode, force_reg (DImode, alpha_compare_op1),
  2160.              alpha_compare_op0);
  2161. }")
  2162.  
  2163. (define_expand "sge"
  2164.   [(set (match_operand:DI 0 "register_operand" "")
  2165.     (match_dup 1))]
  2166.   ""
  2167.   "
  2168. {
  2169.   if (alpha_compare_fp_p)
  2170.     FAIL;
  2171.  
  2172.   operands[1] = gen_rtx (LE, DImode, force_reg (DImode, alpha_compare_op1),
  2173.              alpha_compare_op0);
  2174. }")
  2175.  
  2176. (define_expand "sltu"
  2177.   [(set (match_operand:DI 0 "register_operand" "")
  2178.     (match_dup 1))]
  2179.   ""
  2180.   "
  2181. {
  2182.   if (alpha_compare_fp_p)
  2183.     FAIL;
  2184.  
  2185.   operands[1] = gen_rtx (LTU, DImode, alpha_compare_op0, alpha_compare_op1);
  2186. }")
  2187.  
  2188. (define_expand "sleu"
  2189.   [(set (match_operand:DI 0 "register_operand" "")
  2190.     (match_dup 1))]
  2191.   ""
  2192.   "
  2193. {
  2194.   if (alpha_compare_fp_p)
  2195.     FAIL;
  2196.  
  2197.   operands[1] = gen_rtx (LEU, DImode, alpha_compare_op0, alpha_compare_op1);
  2198. }")
  2199.  
  2200. (define_expand "sgtu"
  2201.   [(set (match_operand:DI 0 "register_operand" "")
  2202.     (match_dup 1))]
  2203.   ""
  2204.   "
  2205. {
  2206.   if (alpha_compare_fp_p)
  2207.     FAIL;
  2208.  
  2209.   operands[1] = gen_rtx (LTU, DImode, force_reg (DImode, alpha_compare_op1),
  2210.              alpha_compare_op0);
  2211. }")
  2212.  
  2213. (define_expand "sgeu"
  2214.   [(set (match_operand:DI 0 "register_operand" "")
  2215.     (match_dup 1))]
  2216.   ""
  2217.   "
  2218. {
  2219.   if (alpha_compare_fp_p)
  2220.     FAIL;
  2221.  
  2222.   operands[1] = gen_rtx (LEU, DImode, force_reg (DImode, alpha_compare_op1),
  2223.              alpha_compare_op0);
  2224. }")
  2225.  
  2226. ;; These are the main define_expand's used to make conditional moves.
  2227.  
  2228. (define_expand "movsicc"
  2229.   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
  2230.    (set (match_operand:SI 0 "register_operand" "")
  2231.     (if_then_else:DI (match_dup 5)
  2232.              (match_operand:SI 2 "reg_or_8bit_operand" "")
  2233.              (match_operand:SI 3 "reg_or_8bit_operand" "")))]
  2234.   ""
  2235.   "
  2236. {
  2237.   rtx op0,op1;
  2238.   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
  2239.  
  2240.   if (alpha_compare_fp_p)
  2241.     FAIL;
  2242.   switch (code)
  2243.     {
  2244.     case EQ: case LE: case LT:
  2245.       op0 = alpha_compare_op0;
  2246.       op1 = alpha_compare_op1;
  2247.       break;
  2248.     case NE:
  2249.       code = code2 = EQ;
  2250.       op0 = alpha_compare_op0;
  2251.       op1 = alpha_compare_op1;
  2252.       break;
  2253.     case GE:
  2254.       code = LE;
  2255.       op0 = force_reg (DImode, alpha_compare_op1);
  2256.       op1 = alpha_compare_op0;
  2257.       break;
  2258.     case GT:
  2259.       code = LT;
  2260.       op0 = force_reg (DImode, alpha_compare_op1);
  2261.       op1 = alpha_compare_op0;
  2262.       break;
  2263.     default:
  2264.       FAIL;
  2265.     }
  2266.   operands[1] = gen_rtx (code, DImode, op0, op1);
  2267.   operands[4] = gen_reg_rtx (DImode);
  2268.   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DImode));
  2269. }")
  2270.  
  2271. (define_expand "movdicc"
  2272.   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
  2273.    (set (match_operand:DI 0 "register_operand" "")
  2274.     (if_then_else:DI (match_dup 5)
  2275.              (match_operand:DI 2 "reg_or_8bit_operand" "")
  2276.              (match_operand:DI 3 "reg_or_8bit_operand" "")))]
  2277.   ""
  2278.   "
  2279. {
  2280.   rtx op0,op1;
  2281.   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
  2282.  
  2283.   if (alpha_compare_fp_p)
  2284.     FAIL;
  2285.   switch (code)
  2286.     {
  2287.     case EQ: case LE: case LT:
  2288.       op0 = alpha_compare_op0;
  2289.       op1 = alpha_compare_op1;
  2290.       break;
  2291.     case NE:
  2292.       code = code2 = EQ;
  2293.       op0 = alpha_compare_op0;
  2294.       op1 = alpha_compare_op1;
  2295.       break;
  2296.     case GE:
  2297.       code = LE;
  2298.       op0 = force_reg (DImode, alpha_compare_op1);
  2299.       op1 = alpha_compare_op0;
  2300.       break;
  2301.     case GT:
  2302.       code = LT;
  2303.       op0 = force_reg (DImode, alpha_compare_op1);
  2304.       op1 = alpha_compare_op0;
  2305.       break;
  2306.     default:
  2307.       FAIL;
  2308.     }
  2309.   operands[1] = gen_rtx (code, DImode, op0, op1);
  2310.   operands[4] = gen_reg_rtx (DImode);
  2311.   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DImode));
  2312. }")
  2313.  
  2314. (define_expand "movsfcc"
  2315.   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
  2316.    (set (match_operand:SF 0 "register_operand" "")
  2317.     (if_then_else:SF (match_dup 5)
  2318.              (match_operand:SF 2 "reg_or_fp0_operand" "")
  2319.              (match_operand:SF 3 "reg_or_fp0_operand" "")))]
  2320.   ""
  2321.   "
  2322. {
  2323.   rtx op0,op1;
  2324.   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
  2325.  
  2326.   if (!alpha_compare_fp_p)
  2327.     FAIL;
  2328.   switch (code)
  2329.     {
  2330.     case EQ: case LE: case LT:
  2331.       op0 = alpha_compare_op0;
  2332.       op1 = alpha_compare_op1;
  2333.       break;
  2334.     case NE:
  2335.       /* There isn't a cmptne insn.  */
  2336.       code = code2 = EQ;
  2337.       op0 = alpha_compare_op0;
  2338.       op1 = alpha_compare_op1;
  2339.       break;
  2340.     case GE:
  2341.       code = LE;
  2342.       op0 = force_reg (DFmode, alpha_compare_op1);
  2343.       op1 = alpha_compare_op0;
  2344.       break;
  2345.     case GT:
  2346.       code = LT;
  2347.       op0 = force_reg (DFmode, alpha_compare_op1);
  2348.       op1 = alpha_compare_op0;
  2349.       break;
  2350.     default:
  2351.       FAIL;
  2352.     }
  2353.   operands[1] = gen_rtx (code, DFmode, op0, op1);
  2354.   operands[4] = gen_reg_rtx (DFmode);
  2355.   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DFmode));
  2356. }")
  2357.  
  2358. (define_expand "movdfcc"
  2359.   [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
  2360.    (set (match_operand:DF 0 "register_operand" "")
  2361.     (if_then_else:DF (match_dup 5)
  2362.              (match_operand:DF 2 "reg_or_fp0_operand" "")
  2363.              (match_operand:DF 3 "reg_or_fp0_operand" "")))]
  2364.   ""
  2365.   "
  2366. {
  2367.   rtx op0,op1;
  2368.   enum rtx_code code = GET_CODE (operands[1]), code2 = NE;
  2369.  
  2370.   if (!alpha_compare_fp_p)
  2371.     FAIL;
  2372.   switch (code)
  2373.     {
  2374.     case EQ: case LE: case LT:
  2375.       op0 = alpha_compare_op0;
  2376.       op1 = alpha_compare_op1;
  2377.       break;
  2378.     case NE:
  2379.       /* There isn't a cmptne insn.  */
  2380.       code = code2 = EQ;
  2381.       op0 = alpha_compare_op0;
  2382.       op1 = alpha_compare_op1;
  2383.       break;
  2384.     case GE:
  2385.       code = LE;
  2386.       op0 = force_reg (DFmode, alpha_compare_op1);
  2387.       op1 = alpha_compare_op0;
  2388.       break;
  2389.     case GT:
  2390.       code = LT;
  2391.       op0 = force_reg (DFmode, alpha_compare_op1);
  2392.       op1 = alpha_compare_op0;
  2393.       break;
  2394.     default:
  2395.       FAIL;
  2396.     }
  2397.   operands[1] = gen_rtx (code, DFmode, op0, op1);
  2398.   operands[4] = gen_reg_rtx (DFmode);
  2399.   operands[5] = gen_rtx (code2, VOIDmode, operands[4], CONST0_RTX (DFmode));
  2400. }")
  2401.  
  2402. ;; These define_split definitions are used in cases when comparisons have
  2403. ;; not be stated in the correct way and we need to reverse the second
  2404. ;; comparison.  For example, x >= 7 has to be done as x < 6 with the
  2405. ;; comparison that tests the result being reversed.  We have one define_split
  2406. ;; for each use of a comparison.  They do not match valid insns and need
  2407. ;; not generate valid insns.
  2408. ;;
  2409. ;; We can also handle equality comparisons (and inequality comparisons in
  2410. ;; cases where the resulting add cannot overflow) by doing an add followed by
  2411. ;; a comparison with zero.  This is faster since the addition takes one
  2412. ;; less cycle than a compare when feeding into a conditional move.
  2413. ;; For this case, we also have an SImode pattern since we can merge the add
  2414. ;; and sign extend and the order doesn't matter.
  2415. ;;
  2416. ;; We do not do this for floating-point, since it isn't clear how the "wrong"
  2417. ;; operation could have been generated.
  2418.  
  2419. (define_split
  2420.   [(set (match_operand:DI 0 "register_operand" "")
  2421.     (if_then_else:DI
  2422.      (match_operator 1 "comparison_operator"
  2423.              [(match_operand:DI 2 "reg_or_0_operand" "")
  2424.               (match_operand:DI 3 "reg_or_cint_operand" "")])
  2425.      (match_operand:DI 4 "reg_or_cint_operand" "")
  2426.      (match_operand:DI 5 "reg_or_cint_operand" "")))
  2427.    (clobber (match_operand:DI 6 "register_operand" ""))]
  2428.   "operands[3] != const0_rtx"
  2429.   [(set (match_dup 6) (match_dup 7))
  2430.    (set (match_dup 0)
  2431.     (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
  2432.   "
  2433. { enum rtx_code code = GET_CODE (operands[1]);
  2434.   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
  2435.  
  2436.   /* If we are comparing for equality with a constant and that constant
  2437.      appears in the arm when the register equals the constant, use the
  2438.      register since that is more likely to match (and to produce better code
  2439.      if both would).  */
  2440.  
  2441.   if (code == EQ && GET_CODE (operands[3]) == CONST_INT
  2442.       && rtx_equal_p (operands[4], operands[3]))
  2443.     operands[4] = operands[2];
  2444.  
  2445.   else if (code == NE && GET_CODE (operands[3]) == CONST_INT
  2446.        && rtx_equal_p (operands[5], operands[3]))
  2447.     operands[5] = operands[2];
  2448.  
  2449.   if (code == NE || code == EQ
  2450.       || (extended_count (operands[2], DImode, unsignedp) >= 1
  2451.       && extended_count (operands[3], DImode, unsignedp) >= 1))
  2452.     {
  2453.       if (GET_CODE (operands[3]) == CONST_INT)
  2454.     operands[7] = gen_rtx (PLUS, DImode, operands[2],
  2455.                    GEN_INT (- INTVAL (operands[3])));
  2456.       else
  2457.     operands[7] = gen_rtx (MINUS, DImode, operands[2], operands[3]);
  2458.  
  2459.       operands[8] = gen_rtx (code, VOIDmode, operands[6], const0_rtx);
  2460.     }
  2461.  
  2462.   else if (code == EQ || code == LE || code == LT
  2463.        || code == LEU || code == LTU)
  2464.     {
  2465.       operands[7] = gen_rtx (code, DImode, operands[2], operands[3]);
  2466.       operands[8] = gen_rtx (NE, VOIDmode, operands[6], const0_rtx);
  2467.     }
  2468.   else
  2469.     {
  2470.       operands[7] = gen_rtx (reverse_condition (code), DImode, operands[2],
  2471.                  operands[3]);
  2472.       operands[8] = gen_rtx (EQ, VOIDmode, operands[6], const0_rtx);
  2473.     }
  2474. }")
  2475.  
  2476. (define_split
  2477.   [(set (match_operand:DI 0 "register_operand" "")
  2478.     (if_then_else:DI
  2479.      (match_operator 1 "comparison_operator"
  2480.              [(match_operand:SI 2 "reg_or_0_operand" "")
  2481.               (match_operand:SI 3 "reg_or_cint_operand" "")])
  2482.      (match_operand:DI 4 "reg_or_8bit_operand" "")
  2483.      (match_operand:DI 5 "reg_or_8bit_operand" "")))
  2484.    (clobber (match_operand:DI 6 "register_operand" ""))]
  2485.   "operands[3] != const0_rtx
  2486.    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
  2487.   [(set (match_dup 6) (match_dup 7))
  2488.    (set (match_dup 0)
  2489.     (if_then_else:DI (match_dup 8) (match_dup 4) (match_dup 5)))]
  2490.   "
  2491. { enum rtx_code code = GET_CODE (operands[1]);
  2492.   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
  2493.   rtx tem;
  2494.  
  2495.   if ((code != NE && code != EQ
  2496.        && ! (extended_count (operands[2], DImode, unsignedp) >= 1
  2497.          && extended_count (operands[3], DImode, unsignedp) >= 1)))
  2498.     FAIL;
  2499.  
  2500.   if (GET_CODE (operands[3]) == CONST_INT)
  2501.     tem = gen_rtx (PLUS, SImode, operands[2],
  2502.            GEN_INT (- INTVAL (operands[3])));
  2503.   else
  2504.     tem = gen_rtx (MINUS, SImode, operands[2], operands[3]);
  2505.  
  2506.   operands[7] = gen_rtx (SIGN_EXTEND, DImode, tem);
  2507.   operands[8] = gen_rtx (GET_CODE (operands[1]), VOIDmode, operands[6],
  2508.              const0_rtx);
  2509. }")
  2510.  
  2511. (define_split
  2512.   [(set (pc)
  2513.     (if_then_else
  2514.      (match_operator 1 "comparison_operator"
  2515.              [(match_operand:DI 2 "reg_or_0_operand" "")
  2516.               (match_operand:DI 3 "reg_or_cint_operand" "")])
  2517.      (label_ref (match_operand 0 "" ""))
  2518.      (pc)))
  2519.    (clobber (match_operand:DI 4 "register_operand" ""))]
  2520.   "operands[3] != const0_rtx"
  2521.   [(set (match_dup 4) (match_dup 5))
  2522.    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
  2523.   "
  2524. { enum rtx_code code = GET_CODE (operands[1]);
  2525.   int unsignedp = (code == GEU || code == LEU || code == GTU || code == LTU);
  2526.  
  2527.   if (code == NE || code == EQ
  2528.       || (extended_count (operands[2], DImode, unsignedp) >= 1
  2529.       && extended_count (operands[3], DImode, unsignedp) >= 1))
  2530.     {
  2531.       if (GET_CODE (operands[3]) == CONST_INT)
  2532.     operands[5] = gen_rtx (PLUS, DImode, operands[2],
  2533.                    GEN_INT (- INTVAL (operands[3])));
  2534.       else
  2535.     operands[5] = gen_rtx (MINUS, DImode, operands[2], operands[3]);
  2536.  
  2537.       operands[6] = gen_rtx (code, VOIDmode, operands[4], const0_rtx);
  2538.     }
  2539.  
  2540.   else if (code == EQ || code == LE || code == LT
  2541.        || code == LEU || code == LTU)
  2542.     {
  2543.       operands[5] = gen_rtx (code, DImode, operands[2], operands[3]);
  2544.       operands[6] = gen_rtx (NE, VOIDmode, operands[4], const0_rtx);
  2545.     }
  2546.   else
  2547.     {
  2548.       operands[5] = gen_rtx (reverse_condition (code), DImode, operands[2],
  2549.                  operands[3]);
  2550.       operands[6] = gen_rtx (EQ, VOIDmode, operands[4], const0_rtx);
  2551.     }
  2552. }")
  2553.  
  2554. (define_split
  2555.   [(set (pc)
  2556.     (if_then_else
  2557.      (match_operator 1 "comparison_operator"
  2558.              [(match_operand:SI 2 "reg_or_0_operand" "")
  2559.               (match_operand:SI 3 "const_int_operand" "")])
  2560.      (label_ref (match_operand 0 "" ""))
  2561.      (pc)))
  2562.    (clobber (match_operand:DI 4 "register_operand" ""))]
  2563.   "operands[3] != const0_rtx
  2564.    && (GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)"
  2565.   [(set (match_dup 4) (match_dup 5))
  2566.    (set (pc) (if_then_else (match_dup 6) (label_ref (match_dup 0)) (pc)))]
  2567.   "
  2568. { rtx tem;
  2569.  
  2570.   if (GET_CODE (operands[3]) == CONST_INT)
  2571.     tem = gen_rtx (PLUS, SImode, operands[2],
  2572.            GEN_INT (- INTVAL (operands[3])));
  2573.   else
  2574.     tem = gen_rtx (MINUS, SImode, operands[2], operands[3]);
  2575.   
  2576.   operands[5] = gen_rtx (SIGN_EXTEND, DImode, tem);
  2577.   operands[6] = gen_rtx (GET_CODE (operands[1]), VOIDmode,
  2578.              operands[4], const0_rtx);
  2579. }")
  2580.  
  2581. ;; We can convert such things as "a > 0xffff" to "t = a & ~ 0xffff; t != 0".
  2582. ;; This eliminates one, and sometimes two, insns when the AND can be done
  2583. ;; with a ZAP.
  2584. (define_split
  2585.   [(set (match_operand:DI 0 "register_operand" "")
  2586.     (match_operator 1 "comparison_operator"
  2587.             [(match_operand:DI 2 "register_operand" "")
  2588.              (match_operand:DI 3 "const_int_operand" "")]))
  2589.    (clobber (match_operand:DI 4 "register_operand" ""))]
  2590.   "exact_log2 (INTVAL (operands[3]) + 1) >= 0
  2591.    && (GET_CODE (operands[1]) == GTU
  2592.        || GET_CODE (operands[1]) == LEU
  2593.        || ((GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == LE)
  2594.        && extended_count (operands[2], DImode, 1) > 0))"
  2595.   [(set (match_dup 4) (and:DI (match_dup 2) (match_dup 5)))
  2596.    (set (match_dup 0) (match_dup 6))]
  2597.   "
  2598. {
  2599.   operands[5] = GEN_INT (~ INTVAL (operands[3]));
  2600.   operands[6] = gen_rtx (((GET_CODE (operands[1]) == GTU
  2601.                || GET_CODE (operands[1]) == GT)
  2602.               ? NE : EQ),
  2603.              DImode, operands[4], const0_rtx);
  2604. }")
  2605.  
  2606. ;; Here are the CALL and unconditional branch insns.  Calls on NT and OSF
  2607. ;; work differently, so we have different patterns for each.
  2608.  
  2609. (define_expand "call"
  2610.   [(use (match_operand:DI 0 "" ""))
  2611.    (use (match_operand 1 "" ""))]
  2612.   ""
  2613.   "
  2614. { if (WINDOWS_NT)
  2615.     emit_call_insn (gen_call_nt (operands[0], operands[1]));
  2616.   else
  2617.     emit_call_insn (gen_call_osf (operands[0], operands[1]));
  2618.  
  2619.   DONE;
  2620. }")
  2621.  
  2622. (define_expand "call_osf"
  2623.   [(parallel [(call (mem:DI (match_operand 0 "" ""))
  2624.             (match_operand 1 "" ""))
  2625.           (clobber (reg:DI 27))
  2626.           (clobber (reg:DI 26))])]
  2627.   ""
  2628.   "
  2629. { if (GET_CODE (operands[0]) != MEM)
  2630.     abort ();
  2631.  
  2632.   operands[0] = XEXP (operands[0], 0);
  2633.  
  2634.   if (GET_CODE (operands[0]) != SYMBOL_REF
  2635.       && ! (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 27))
  2636.     {
  2637.       rtx tem = gen_rtx (REG, DImode, 27);
  2638.       emit_move_insn (tem, operands[0]);
  2639.       operands[0] = tem;
  2640.     }
  2641. }")
  2642.  
  2643. (define_expand "call_nt"
  2644.   [(parallel [(call (mem:DI (match_operand:DI 0 "" ""))
  2645.             (match_operand 1 "" ""))
  2646.           (clobber (reg:DI 26))])]
  2647.   ""
  2648.   "
  2649. { if (GET_CODE (operands[0]) != MEM)
  2650.     abort ();
  2651.   operands[0] = XEXP (operands[0], 0);
  2652.  
  2653.   if (GET_CODE (operands[0]) != SYMBOL_REF)
  2654.     operands[0] = force_reg (Pmode, operands[0]);
  2655. }")
  2656.  
  2657. (define_expand "call_value"
  2658.   [(use (match_operand 0 "" ""))
  2659.    (use (match_operand:DI 1 "" ""))
  2660.    (use (match_operand 2 "" ""))]
  2661.   ""
  2662.   "
  2663. { if (WINDOWS_NT)
  2664.     emit_call_insn (gen_call_value_nt (operands[0], operands[1], operands[2]));
  2665.   else
  2666.     emit_call_insn (gen_call_value_osf (operands[0], operands[1],
  2667.                     operands[2]));
  2668.   DONE;
  2669. }")
  2670.  
  2671. (define_expand "call_value_osf"
  2672.   [(parallel [(set (match_operand 0 "" "")
  2673.            (call (mem:DI (match_operand 1 "" ""))
  2674.              (match_operand 2 "" "")))
  2675.           (clobber (reg:DI 27))
  2676.           (clobber (reg:DI 26))])]
  2677.   ""
  2678.   "
  2679. { if (GET_CODE (operands[1]) != MEM)
  2680.     abort ();
  2681.  
  2682.   operands[1] = XEXP (operands[1], 0);
  2683.  
  2684.   if (GET_CODE (operands[1]) != SYMBOL_REF
  2685.       && ! (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 27))
  2686.     {
  2687.       rtx tem = gen_rtx (REG, DImode, 27);
  2688.       emit_move_insn (tem, operands[1]);
  2689.       operands[1] = tem;
  2690.     }
  2691. }")
  2692.  
  2693. (define_expand "call_value_nt"
  2694.   [(parallel [(set (match_operand 0 "" "")
  2695.            (call (mem:DI (match_operand:DI 1 "" ""))
  2696.              (match_operand 2 "" "")))
  2697.           (clobber (reg:DI 26))])]
  2698.   ""
  2699.   "
  2700. { if (GET_CODE (operands[1]) != MEM)
  2701.     abort ();
  2702.  
  2703.   operands[1] = XEXP (operands[1], 0);
  2704.   if (GET_CODE (operands[1]) != SYMBOL_REF)
  2705.     operands[1] = force_reg (Pmode, operands[1]);
  2706. }")
  2707.  
  2708. (define_insn ""
  2709.   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,R,i"))
  2710.      (match_operand 1 "" ""))
  2711.    (clobber (reg:DI 27))
  2712.    (clobber (reg:DI 26))]
  2713.   "! WINDOWS_NT"
  2714.   "@
  2715.    jsr $26,($27),0\;ldgp $29,0($26)
  2716.    bsr $26,%0..ng
  2717.    jsr $26,%0\;ldgp $29,0($26)"
  2718.   [(set_attr "type" "jsr,jsr,ibr")])
  2719.       
  2720. (define_insn ""
  2721.   [(call (mem:DI (match_operand:DI 0 "call_operand" "r,i"))
  2722.      (match_operand 1 "" ""))
  2723.    (clobber (reg:DI 26))]
  2724.   "WINDOWS_NT"
  2725.   "@
  2726.    jsr $26,(%0)
  2727.    bsr $26,%0"
  2728.   [(set_attr "type" "jsr")])
  2729.       
  2730. (define_insn ""
  2731.   [(set (match_operand 0 "register_operand" "=rf,rf,rf")
  2732.     (call (mem:DI (match_operand:DI 1 "call_operand" "r,R,i"))
  2733.           (match_operand 2 "" "")))
  2734.    (clobber (reg:DI 27))
  2735.    (clobber (reg:DI 26))]
  2736.   "! WINDOWS_NT"
  2737.   "@
  2738.    jsr $26,($27),0\;ldgp $29,0($26)
  2739.    bsr $26,%1..ng
  2740.    jsr $26,%1\;ldgp $29,0($26)"
  2741.   [(set_attr "type" "jsr,jsr,ibr")])
  2742.  
  2743. (define_insn ""
  2744.   [(set (match_operand 0 "register_operand" "=rf,rf")
  2745.     (call (mem:DI (match_operand:DI 1 "call_operand" "r,i"))
  2746.           (match_operand 2 "" "")))
  2747.    (clobber (reg:DI 26))]
  2748.   "WINDOWS_NT"
  2749.   "@
  2750.    jsr $26,(%1)
  2751.    bsr $26,%1"
  2752.   [(set_attr "type" "jsr")])
  2753.  
  2754. ;; Call subroutine returning any type.
  2755.  
  2756. (define_expand "untyped_call"
  2757.   [(parallel [(call (match_operand 0 "" "")
  2758.             (const_int 0))
  2759.           (match_operand 1 "" "")
  2760.           (match_operand 2 "" "")])]
  2761.   ""
  2762.   "
  2763. {
  2764.   int i;
  2765.  
  2766.   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
  2767.  
  2768.   for (i = 0; i < XVECLEN (operands[2], 0); i++)
  2769.     {
  2770.       rtx set = XVECEXP (operands[2], 0, i);
  2771.       emit_move_insn (SET_DEST (set), SET_SRC (set));
  2772.     }
  2773.  
  2774.   /* The optimizer does not know that the call sets the function value
  2775.      registers we stored in the result block.  We avoid problems by
  2776.      claiming that all hard registers are used and clobbered at this
  2777.      point.  */
  2778.   emit_insn (gen_blockage ());
  2779.  
  2780.   DONE;
  2781. }")
  2782.  
  2783. ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
  2784. ;; all of memory.  This blocks insns from being moved across this point.
  2785.  
  2786. (define_insn "blockage"
  2787.   [(unspec_volatile [(const_int 0)] 1)]
  2788.   ""
  2789.   "")
  2790.  
  2791. (define_insn "jump"
  2792.   [(set (pc)
  2793.     (label_ref (match_operand 0 "" "")))]
  2794.   ""
  2795.   "br $31,%l0"
  2796.   [(set_attr "type" "ibr")])
  2797.  
  2798. (define_insn "return"
  2799.   [(return)]
  2800.   "direct_return ()"
  2801.   "ret $31,($26),1"
  2802.   [(set_attr "type" "ibr")])
  2803.  
  2804. (define_insn "indirect_jump"
  2805.   [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
  2806.   ""
  2807.   "jmp $31,(%0),0"
  2808.   [(set_attr "type" "ibr")])
  2809.  
  2810. (define_insn "nop"
  2811.   [(const_int 0)]
  2812.   ""
  2813.   "bis $31,$31,$31"
  2814.   [(set_attr "type" "iaddlog")])
  2815.  
  2816. (define_expand "tablejump"
  2817.   [(use (match_operand:SI 0 "register_operand" ""))
  2818.    (use (match_operand:SI 1 "" ""))]
  2819.   ""
  2820.   "
  2821. {
  2822.   if (WINDOWS_NT)
  2823.     emit_jump_insn (gen_tablejump_nt (operands[0], operands[1]));
  2824.   else
  2825.     emit_jump_insn (gen_tablejump_osf (operands[0], operands[1]));
  2826.  
  2827.   DONE;
  2828. }")
  2829.  
  2830. (define_expand "tablejump_osf"
  2831.   [(set (match_dup 3)
  2832.     (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
  2833.    (parallel [(set (pc)
  2834.            (plus:DI (match_dup 3)
  2835.                 (label_ref:DI (match_operand 1 "" ""))))
  2836.           (clobber (match_scratch:DI 2 "=r"))])]
  2837.   ""
  2838.   "
  2839. { operands[3] = gen_reg_rtx (DImode); }")
  2840.  
  2841. (define_expand "tablejump_nt"
  2842.   [(set (match_dup 3)
  2843.     (sign_extend:DI (match_operand:SI 0 "register_operand" "")))
  2844.    (parallel [(set (pc)
  2845.            (match_dup 3))
  2846.           (use (label_ref (match_operand 1 "" "")))])]
  2847.   ""
  2848.   "
  2849. { operands[3] = gen_reg_rtx (DImode); }")
  2850.  
  2851. (define_insn ""
  2852.   [(set (pc)
  2853.     (plus:DI (match_operand:DI 0 "register_operand" "r")
  2854.          (label_ref:DI (match_operand 1 "" ""))))
  2855.    (clobber (match_scratch:DI 2 "=r"))]
  2856.   "! WINDOWS_NT && next_active_insn (insn) != 0
  2857.    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
  2858.    && PREV_INSN (next_active_insn (insn)) == operands[1]"
  2859.   "*
  2860. { rtx best_label = 0;
  2861.   rtx jump_table_insn = next_active_insn (operands[1]);
  2862.  
  2863.   if (GET_CODE (jump_table_insn) == JUMP_INSN
  2864.       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
  2865.     {
  2866.       rtx jump_table = PATTERN (jump_table_insn);
  2867.       int n_labels = XVECLEN (jump_table, 1);
  2868.       int best_count = -1;
  2869.       int i, j;
  2870.  
  2871.       for (i = 0; i < n_labels; i++)
  2872.     {
  2873.       int count = 1;
  2874.  
  2875.       for (j = i + 1; j < n_labels; j++)
  2876.         if (XEXP (XVECEXP (jump_table, 1, i), 0)
  2877.         == XEXP (XVECEXP (jump_table, 1, j), 0))
  2878.           count++;
  2879.  
  2880.       if (count > best_count)
  2881.         best_count = count, best_label = XVECEXP (jump_table, 1, i);
  2882.     }
  2883.     }
  2884.  
  2885.   if (best_label)
  2886.     {
  2887.       operands[3] = best_label;
  2888.       return \"addq %0,$29,%2\;jmp $31,(%2),%3\";
  2889.     }
  2890.   else
  2891.     return \"addq %0,$29,%2\;jmp $31,(%2),0\";
  2892. }"
  2893.   [(set_attr "type" "ibr")])
  2894.  
  2895. (define_insn ""
  2896.   [(set (pc)
  2897.     (match_operand:DI 0 "register_operand" "r"))
  2898.    (use (label_ref (match_operand 1 "" "")))]
  2899.   "WINDOWS_NT && next_active_insn (insn) != 0
  2900.    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
  2901.    && PREV_INSN (next_active_insn (insn)) == operands[1]"
  2902.   "*
  2903. { rtx best_label = 0;
  2904.   rtx jump_table_insn = next_active_insn (operands[1]);
  2905.  
  2906.   if (GET_CODE (jump_table_insn) == JUMP_INSN
  2907.       && GET_CODE (PATTERN (jump_table_insn)) == ADDR_DIFF_VEC)
  2908.     {
  2909.       rtx jump_table = PATTERN (jump_table_insn);
  2910.       int n_labels = XVECLEN (jump_table, 1);
  2911.       int best_count = -1;
  2912.       int i, j;
  2913.  
  2914.       for (i = 0; i < n_labels; i++)
  2915.     {
  2916.       int count = 1;
  2917.  
  2918.       for (j = i + 1; j < n_labels; j++)
  2919.         if (XEXP (XVECEXP (jump_table, 1, i), 0)
  2920.         == XEXP (XVECEXP (jump_table, 1, j), 0))
  2921.           count++;
  2922.  
  2923.       if (count > best_count)
  2924.         best_count = count, best_label = XVECEXP (jump_table, 1, i);
  2925.     }
  2926.     }
  2927.  
  2928.   if (best_label)
  2929.     {
  2930.       operands[2] = best_label;
  2931.       return \"jmp $31,(%0),%2\";
  2932.     }
  2933.   else
  2934.     return \"jmp $31,(%0),0\";
  2935. }"
  2936.   [(set_attr "type" "ibr")])
  2937.  
  2938. ;; Cache flush.  Used by INITIALIZE_TRAMPOLINE.  0x86 is PAL_imb, but we don't
  2939. ;; want to have to include pal.h in our .s file.
  2940. (define_insn ""
  2941.   [(unspec_volatile [(const_int 0)] 0)]
  2942.   ""
  2943.   "call_pal 0x86")
  2944.  
  2945. ;; Finally, we have the basic data motion insns.  The byte and word insns
  2946. ;; are done via define_expand.  Start with the floating-point insns, since
  2947. ;; they are simpler.
  2948.  
  2949. (define_insn ""
  2950.   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,f,f,f,m")
  2951.     (match_operand:SF 1 "input_operand" "rG,m,rG,f,G,m,fG"))]
  2952.   "register_operand (operands[0], SFmode)
  2953.    || reg_or_fp0_operand (operands[1], SFmode)"
  2954.   "@
  2955.    bis %r1,%r1,%0
  2956.    ldl %0,%1
  2957.    stl %r1,%0
  2958.    cpys %1,%1,%0
  2959.    cpys $f31,$f31,%0
  2960.    lds %0,%1
  2961.    sts %R1,%0"
  2962.   [(set_attr "type" "iaddlog,ld,st,fpop,fpop,ld,st")])
  2963.  
  2964. (define_insn ""
  2965.   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,f,f,f,m")
  2966.     (match_operand:DF 1 "input_operand" "rG,m,rG,f,G,m,fG"))]
  2967.   "register_operand (operands[0], DFmode)
  2968.    || reg_or_fp0_operand (operands[1], DFmode)"
  2969.   "@
  2970.    bis %r1,%r1,%0
  2971.    ldq %0,%1
  2972.    stq %r1,%0
  2973.    cpys %1,%1,%0
  2974.    cpys $f31,$f31,%0
  2975.    ldt %0,%1
  2976.    stt %R1,%0"
  2977.   [(set_attr "type" "iaddlog,ld,st,fpop,fpop,ld,st")])
  2978.  
  2979. (define_expand "movsf"
  2980.   [(set (match_operand:SF 0 "nonimmediate_operand" "")
  2981.     (match_operand:SF 1 "general_operand" ""))]
  2982.   ""
  2983.   "
  2984. {
  2985.   if (GET_CODE (operands[0]) == MEM
  2986.       && ! reg_or_fp0_operand (operands[1], SFmode))
  2987.     operands[1] = force_reg (SFmode, operands[1]);
  2988. }")
  2989.  
  2990. (define_expand "movdf"
  2991.   [(set (match_operand:DF 0 "nonimmediate_operand" "")
  2992.     (match_operand:DF 1 "general_operand" ""))]
  2993.   ""
  2994.   "
  2995. {
  2996.   if (GET_CODE (operands[0]) == MEM
  2997.       && ! reg_or_fp0_operand (operands[1], DFmode))
  2998.     operands[1] = force_reg (DFmode, operands[1]);
  2999. }")
  3000.  
  3001. (define_insn ""
  3002.   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,f,f,f,m")
  3003.     (match_operand:SI 1 "input_operand" "r,J,I,K,L,m,rJ,f,J,m,fG"))]
  3004.   "! WINDOWS_NT && (register_operand (operands[0], SImode)
  3005.             || reg_or_0_operand (operands[1], SImode))"
  3006.   "@
  3007.    bis %1,%1,%0
  3008.    bis $31,$31,%0
  3009.    bis $31,%1,%0
  3010.    lda %0,%1
  3011.    ldah %0,%h1
  3012.    ldl %0,%1
  3013.    stl %r1,%0
  3014.    cpys %1,%1,%0
  3015.    cpys $f31,$f31,%0
  3016.    lds %0,%1
  3017.    sts %R1,%0"
  3018.   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ld,st,fpop,fpop,ld,st")])
  3019.  
  3020. (define_insn ""
  3021.   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,r,r,m,f,f,f,m")
  3022.     (match_operand:SI 1 "input_operand" "r,J,I,K,L,s,m,rJ,f,J,m,fG"))]
  3023.   "WINDOWS_NT && (register_operand (operands[0], SImode)
  3024.           || reg_or_0_operand (operands[1], SImode))"
  3025.   "@
  3026.    bis %1,%1,%0
  3027.    bis $31,$31,%0
  3028.    bis $31,%1,%0
  3029.    lda %0,%1
  3030.    ldah %0,%h1
  3031.    lda %0,%1
  3032.    ldl %0,%1
  3033.    stl %r1,%0
  3034.    cpys %1,%1,%0
  3035.    cpys $f31,$f31,%0
  3036.    lds %0,%1
  3037.    sts %R1,%0"
  3038.   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ldsym,ld,st,fpop,fpop,ld,st")])
  3039.  
  3040. (define_insn ""
  3041.   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,r,f,f")
  3042.     (match_operand:HI 1 "input_operand" "r,J,I,n,f,J"))]
  3043.   "register_operand (operands[0], HImode)
  3044.    || register_operand (operands[1], HImode)"
  3045.   "@
  3046.    bis %1,%1,%0
  3047.    bis $31,$31,%0
  3048.    bis $31,%1,%0
  3049.    lda %0,%L1
  3050.    cpys %1,%1,%0
  3051.    cpys $f31,$f31,%0"
  3052.   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,fpop,fpop")])
  3053.  
  3054. (define_insn ""
  3055.   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,r,f,f")
  3056.     (match_operand:QI 1 "input_operand" "r,J,I,n,f,J"))]
  3057.   "register_operand (operands[0], QImode)
  3058.    || register_operand (operands[1], QImode)"
  3059.   "@
  3060.    bis %1,%1,%0
  3061.    bis $31,$31,%0
  3062.    bis $31,%1,%0
  3063.    lda %0,%L1
  3064.    cpys %1,%1,%0
  3065.    cpys $f31,$f31,%0"
  3066.   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,fpop,fpop")])
  3067.  
  3068. ;; We do two major things here: handle mem->mem and construct long
  3069. ;; constants.
  3070.  
  3071. (define_expand "movsi"
  3072.   [(set (match_operand:SI 0 "general_operand" "")
  3073.     (match_operand:SI 1 "general_operand" ""))]
  3074.   ""
  3075.   "
  3076. {
  3077.   if (GET_CODE (operands[0]) == MEM
  3078.       && ! reg_or_0_operand (operands[1], SImode))
  3079.     operands[1] = force_reg (SImode, operands[1]);
  3080.  
  3081.   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
  3082.     ;
  3083.   else if (GET_CODE (operands[1]) == CONST_INT)
  3084.     {
  3085.       operands[1]
  3086.     = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 3);
  3087.       if (rtx_equal_p (operands[0], operands[1]))
  3088.     DONE;
  3089.     }
  3090. }")
  3091.  
  3092. ;; Split a load of a large constant into the appropriate two-insn
  3093. ;; sequence.
  3094.  
  3095. (define_split
  3096.   [(set (match_operand:SI 0 "register_operand" "")
  3097.     (match_operand:SI 1 "const_int_operand" ""))]
  3098.   "! add_operand (operands[1], SImode)"
  3099.   [(set (match_dup 0) (match_dup 2))
  3100.    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
  3101.   "
  3102. { rtx tem
  3103.     = alpha_emit_set_const (operands[0], SImode, INTVAL (operands[1]), 2);
  3104.  
  3105.   if (tem == operands[0])
  3106.     DONE;
  3107.   else
  3108.     FAIL;
  3109. }")
  3110.  
  3111. (define_insn ""
  3112.   [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,r,r,r,m,f,f,f,Q")
  3113.     (match_operand:DI 1 "input_operand" "r,J,I,K,L,s,m,rJ,f,J,Q,fG"))]
  3114.   "register_operand (operands[0], DImode)
  3115.    || reg_or_0_operand (operands[1], DImode)"
  3116.   "@
  3117.    bis %1,%1,%0
  3118.    bis $31,$31,%0
  3119.    bis $31,%1,%0
  3120.    lda %0,%1
  3121.    ldah %0,%h1
  3122.    lda %0,%1
  3123.    ldq%A1 %0,%1
  3124.    stq%A0 %r1,%0
  3125.    cpys %1,%1,%0
  3126.    cpys $f31,$f31,%0
  3127.    ldt %0,%1
  3128.    stt %R1,%0"
  3129.   [(set_attr "type" "iaddlog,iaddlog,iaddlog,iaddlog,iaddlog,ldsym,ld,st,fpop,fpop,ld,st")])
  3130.  
  3131. ;; We do three major things here: handle mem->mem, put 64-bit constants in
  3132. ;; memory, and construct long 32-bit constants.
  3133.  
  3134. (define_expand "movdi"
  3135.   [(set (match_operand:DI 0 "general_operand" "")
  3136.     (match_operand:DI 1 "general_operand" ""))]
  3137.   ""
  3138.   "
  3139. {
  3140.   rtx tem;
  3141.  
  3142.   if (GET_CODE (operands[0]) == MEM
  3143.       && ! reg_or_0_operand (operands[1], DImode))
  3144.     operands[1] = force_reg (DImode, operands[1]);
  3145.  
  3146.   if (! CONSTANT_P (operands[1]) || input_operand (operands[1], DImode))
  3147.     ;
  3148.   else if (GET_CODE (operands[1]) == CONST_INT
  3149.        && (tem = alpha_emit_set_const (operands[0], DImode,
  3150.                        INTVAL (operands[1]), 3)) != 0)
  3151.     {
  3152.       if (rtx_equal_p (tem, operands[0]))
  3153.     DONE;
  3154.       else
  3155.     operands[1] = tem;
  3156.     }
  3157.   else if (CONSTANT_P (operands[1]))
  3158.     {
  3159.       operands[1] = force_const_mem (DImode, operands[1]);
  3160.       if (reload_in_progress)
  3161.     {
  3162.       emit_move_insn (operands[0], XEXP (operands[1], 0));
  3163.       XEXP (operands[1], 0) = operands[0];
  3164.     }
  3165.       else
  3166.     operands[1] = validize_mem (operands[1]);
  3167.     }
  3168.   else
  3169.     abort ();
  3170. }")
  3171.  
  3172. ;; Split a load of a large constant into the appropriate two-insn
  3173. ;; sequence.
  3174.  
  3175. (define_split
  3176.   [(set (match_operand:DI 0 "register_operand" "")
  3177.     (match_operand:DI 1 "const_int_operand" ""))]
  3178.   "! add_operand (operands[1], DImode)"
  3179.   [(set (match_dup 0) (match_dup 2))
  3180.    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
  3181.   "
  3182. { rtx tem
  3183.     = alpha_emit_set_const (operands[0], DImode, INTVAL (operands[1]), 2);
  3184.  
  3185.   if (tem == operands[0])
  3186.     DONE;
  3187.   else
  3188.     FAIL;
  3189. }")
  3190.  
  3191. ;; These are the partial-word cases.
  3192. ;;
  3193. ;; First we have the code to load an aligned word.  Operand 0 is the register
  3194. ;; in which to place the result.  It's mode is QImode or HImode.  Operand 1
  3195. ;; is an SImode MEM at the low-order byte of the proper word.  Operand 2 is the
  3196. ;; number of bits within the word that the value is.  Operand 3 is an SImode
  3197. ;; scratch register.  If operand 0 is a hard register, operand 3 may be the
  3198. ;; same register.  It is allowed to conflict with operand 1 as well.
  3199.  
  3200. (define_expand "aligned_loadqi"
  3201.   [(set (match_operand:SI 3 "register_operand" "")
  3202.     (match_operand:SI 1 "memory_operand" ""))
  3203.    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
  3204.     (zero_extract:DI (subreg:DI (match_dup 3) 0)
  3205.              (const_int 8)
  3206.              (match_operand:DI 2 "const_int_operand" "")))]
  3207.      
  3208.   ""
  3209.   "")
  3210.   
  3211. (define_expand "aligned_loadhi"
  3212.   [(set (match_operand:SI 3 "register_operand" "")
  3213.     (match_operand:SI 1 "memory_operand" ""))
  3214.    (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
  3215.     (zero_extract:DI (subreg:DI (match_dup 3) 0)
  3216.              (const_int 16)
  3217.              (match_operand:DI 2 "const_int_operand" "")))]
  3218.      
  3219.   ""
  3220.   "")
  3221.   
  3222. ;; Similar for unaligned loads.  For QImode, we use the sequence from the
  3223. ;; Alpha Architecture manual.  However, for HImode, we do not.  HImode pointers
  3224. ;; are normally aligned to the byte boundary, so an HImode object cannot
  3225. ;; cross a longword boundary.  We could use a sequence similar to that for
  3226. ;; QImode, but that would fail if the pointer, was, in fact, not aligned.
  3227. ;; Instead, we clear bit 1 in the address and do an ldl.  If the low-order
  3228. ;; bit was not aligned, this will trap and the trap handler will do what is
  3229. ;; needed.
  3230. ;;
  3231. ;; Here operand 1 is the address.  Operands 2 and 3 are temporaries, where
  3232. ;; operand 3 can overlap the input and output registers.
  3233.  
  3234. (define_expand "unaligned_loadqi"
  3235.   [(set (match_operand:DI 2 "register_operand" "")
  3236.     (mem:DI (and:DI (match_operand:DI 1 "address_operand" "")
  3237.             (const_int -8))))
  3238.    (set (match_operand:DI 3 "register_operand" "")
  3239.     (match_dup 1))
  3240.    (set (subreg:DI (match_operand:QI 0 "register_operand" "") 0)
  3241.     (zero_extract:DI (match_dup 2)
  3242.              (const_int 8)
  3243.              (ashift:DI (match_dup 3) (const_int 3))))]
  3244.   ""
  3245.   "")
  3246.  
  3247. ;; For this, the address must already be in a register.  We also need two
  3248. ;; DImode temporaries, neither of which may overlap the input (and hence the
  3249. ;; output, since they might be the same register), but both of which may
  3250. ;; be the same.
  3251.  
  3252. (define_expand "unaligned_loadhi"
  3253.   [(set (match_operand:DI 2 "register_operand" "")
  3254.     (and:DI (match_operand:DI 1 "register_operand" "")
  3255.         (const_int -7)))
  3256.    (set (match_operand:DI 3 "register_operand" "")
  3257.     (mem:DI (match_dup 2)))
  3258.    (set (match_operand:DI 4 "register_operand" "")
  3259.     (and:DI (match_dup 1) (const_int -2)))
  3260.    (set (subreg:DI (match_operand:HI 0 "register_operand" "") 0)
  3261.     (zero_extract:DI (match_dup 3)
  3262.              (const_int 16)
  3263.              (ashift:DI (match_dup 4) (const_int 3))))]
  3264.   ""
  3265.   "")
  3266.        
  3267. ;; Storing an aligned byte or word requires two temporaries.  Operand 0 is the
  3268. ;; aligned SImode MEM.  Operand 1 is the register containing the 
  3269. ;; byte or word to store.  Operand 2 is the number of bits within the word that
  3270. ;; the value should be placed.  Operands 3 and 4 are SImode temporaries.
  3271.  
  3272. (define_expand "aligned_store"
  3273.   [(set (match_operand:SI 3 "register_operand" "")
  3274.     (match_operand:SI 0 "memory_operand" ""))
  3275.    (set (subreg:DI (match_dup 3) 0)
  3276.     (and:DI (subreg:DI (match_dup 3) 0) (match_dup 5)))
  3277.    (set (subreg:DI (match_operand:SI 4 "register_operand" "") 0)
  3278.     (ashift:DI (zero_extend:DI (match_operand 1 "register_operand" ""))
  3279.            (match_operand:DI 2 "const_int_operand" "")))
  3280.    (set (subreg:DI (match_dup 4) 0)
  3281.     (ior:DI (subreg:DI (match_dup 4) 0) (subreg:DI (match_dup 3) 0)))
  3282.    (set (match_dup 0) (match_dup 4))]
  3283.   ""
  3284.   "
  3285. { operands[5] = GEN_INT (~ (GET_MODE_MASK (GET_MODE (operands[1]))
  3286.                 << INTVAL (operands[2])));
  3287. }")
  3288.  
  3289. ;; For the unaligned byte case, we use code similar to that in the
  3290. ;; Architecture book, but reordered to lower the number of registers
  3291. ;; required.  Operand 0 is the address.  Operand 1 is the data to store.
  3292. ;; Operands 2, 3, and 4 are DImode temporaries, where operands 2 and 4 may
  3293. ;; be the same temporary, if desired.  If the address is in a register,
  3294. ;; operand 2 can be that register.
  3295.  
  3296. (define_expand "unaligned_storeqi"
  3297.   [(set (match_operand:DI 3 "register_operand" "")
  3298.     (mem:DI (and:DI (match_operand:DI 0 "address_operand" "")
  3299.             (const_int -8))))
  3300.    (set (match_operand:DI 2 "register_operand" "")
  3301.     (match_dup 0))
  3302.    (set (match_dup 3)
  3303.     (and:DI (not:DI (ashift:DI (const_int 255)
  3304.                    (ashift:DI (match_dup 2) (const_int 3))))
  3305.         (match_dup 3)))
  3306.    (set (match_operand:DI 4 "register_operand" "")
  3307.     (ashift:DI (zero_extend:DI (match_operand:QI 1 "register_operand" ""))
  3308.            (ashift:DI (match_dup 2) (const_int 3))))
  3309.    (set (match_dup 4) (ior:DI (match_dup 4) (match_dup 3)))
  3310.    (set (mem:DI (and:DI (match_dup 0) (const_int -8)))
  3311.     (match_dup 4))]
  3312.   ""
  3313.   "")
  3314.  
  3315. ;; This is the code for storing into an unaligned short.  It uses the same
  3316. ;; trick as loading from an unaligned short.  It needs lots of temporaries.
  3317. ;; However, during reload, we only have two registers available.  So we
  3318. ;; repeat code so that only two temporaries are available.  During RTL
  3319. ;; generation, we can use different pseudos for each temporary and CSE
  3320. ;; will remove the redundancies.  During reload, we have to settle with
  3321. ;; what we get.  Luckily, unaligned accesses of this kind produced during
  3322. ;; reload are quite rare.
  3323. ;;
  3324. ;; Operand 0 is the address of the memory location.  Operand 1 contains the
  3325. ;; data to store.  The rest of the operands are all temporaries, with
  3326. ;; various overlap possibilities during reload.  See reload_outhi for
  3327. ;; details of this use.
  3328.  
  3329. (define_expand "unaligned_storehi"
  3330.   [(set (match_operand:DI 2 "register_operand" "")
  3331.     (match_operand:DI 0 "address_operand" ""))
  3332.    (set (match_operand:DI 3 "register_operand" "")
  3333.     (and:DI (match_dup 2) (const_int -7)))
  3334.    (set (match_operand:DI 4 "register_operand" "")
  3335.     (mem:DI (match_dup 3)))
  3336.    (set (match_operand:DI 10 "register_operand" "")
  3337.     (and:DI (match_dup 2) (const_int -2)))
  3338.    (set (match_operand:DI 5 "register_operand" "")
  3339.     (and:DI (not:DI (ashift:DI (const_int 65535)
  3340.                    (ashift:DI (match_dup 10) (const_int 3))))
  3341.         (match_dup 4)))
  3342.    (set (match_operand:DI 6 "register_operand" "")
  3343.     (ashift:DI (zero_extend:DI (match_operand:HI 1 "register_operand" ""))
  3344.            (ashift:DI (match_dup 10) (const_int 3))))
  3345.    (set (match_operand:DI 7 "register_operand" "")
  3346.     (ior:DI (match_dup 5) (match_dup 6)))
  3347.    (set (match_operand:DI 8 "register_operand" "") (match_dup 0))
  3348.    (set (match_operand:DI 9 "register_operand" "")
  3349.     (and:DI (match_dup 8) (const_int -7)))
  3350.    (set (mem:DI (match_dup 9)) (match_dup 7))]
  3351.   ""
  3352.   "")
  3353.  
  3354. ;; Here are the define_expand's for QI and HI moves that use the above
  3355. ;; patterns.  We have the normal sets, plus the ones that need scratch
  3356. ;; registers for reload.
  3357.  
  3358. (define_expand "movqi"
  3359.   [(set (match_operand:QI 0 "general_operand" "")
  3360.     (match_operand:QI 1 "general_operand" ""))]
  3361.   ""
  3362.   "
  3363. { extern rtx get_unaligned_address ();
  3364.  
  3365.   /* If the output is not a register, the input must be.  */
  3366.   if (GET_CODE (operands[0]) == MEM)
  3367.     operands[1] = force_reg (QImode, operands[1]);
  3368.  
  3369.   /* Handle four memory cases, unaligned and aligned for either the input
  3370.      or the output.  The only case where we can be called during reload is
  3371.      for aligned loads; all other cases require temporaries.  */
  3372.  
  3373.   if (GET_CODE (operands[1]) == MEM
  3374.       || (GET_CODE (operands[1]) == SUBREG
  3375.       && GET_CODE (SUBREG_REG (operands[1])) == MEM)
  3376.       || (reload_in_progress && GET_CODE (operands[1]) == REG
  3377.       && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
  3378.       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
  3379.       && GET_CODE (SUBREG_REG (operands[1])) == REG
  3380.       && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
  3381.     {
  3382.       if (aligned_memory_operand (operands[1], QImode))
  3383.     {
  3384.       rtx aligned_mem, bitnum;
  3385.       rtx scratch = (reload_in_progress
  3386.              ? gen_rtx (REG, SImode, REGNO (operands[0]))
  3387.              : gen_reg_rtx (SImode));
  3388.  
  3389.       get_aligned_mem (operands[1], &aligned_mem, &bitnum);
  3390.  
  3391.       emit_insn (gen_aligned_loadqi (operands[0], aligned_mem, bitnum,
  3392.                      scratch));
  3393.     }
  3394.       else
  3395.     {
  3396.       /* Don't pass these as parameters since that makes the generated
  3397.          code depend on parameter evaluation order which will cause
  3398.          bootstrap failures.  */
  3399.  
  3400.       rtx temp1 = gen_reg_rtx (DImode);
  3401.       rtx temp2 = gen_reg_rtx (DImode);
  3402.       rtx seq = gen_unaligned_loadqi (operands[0],
  3403.                       get_unaligned_address (operands[1]),
  3404.                       temp1, temp2);
  3405.  
  3406.       alpha_set_memflags (seq, operands[1]);
  3407.       emit_insn (seq);
  3408.     }
  3409.  
  3410.       DONE;
  3411.     }
  3412.  
  3413.   else if (GET_CODE (operands[0]) == MEM
  3414.        || (GET_CODE (operands[0]) == SUBREG 
  3415.            && GET_CODE (SUBREG_REG (operands[0])) == MEM)
  3416.        || (reload_in_progress && GET_CODE (operands[0]) == REG
  3417.            && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
  3418.        || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
  3419.            && GET_CODE (SUBREG_REG (operands[0])) == REG
  3420.            && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
  3421.     {
  3422.       if (aligned_memory_operand (operands[0], QImode))
  3423.     {
  3424.       rtx aligned_mem, bitnum;
  3425.       rtx temp1 = gen_reg_rtx (SImode);
  3426.       rtx temp2 = gen_reg_rtx (SImode);
  3427.  
  3428.       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
  3429.  
  3430.       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
  3431.                     temp1, temp2));
  3432.     }
  3433.       else
  3434.     {
  3435.       rtx temp1 = gen_reg_rtx (DImode);
  3436.       rtx temp2 = gen_reg_rtx (DImode);
  3437.       rtx temp3 = gen_reg_rtx (DImode);
  3438.       rtx seq = gen_unaligned_storeqi (get_unaligned_address (operands[0]),
  3439.                        operands[1], temp1, temp2, temp3);
  3440.  
  3441.       alpha_set_memflags (seq, operands[0]);
  3442.       emit_insn (seq);
  3443.     }
  3444.       DONE;
  3445.     }
  3446. }")
  3447.  
  3448. (define_expand "movhi"
  3449.   [(set (match_operand:HI 0 "general_operand" "")
  3450.     (match_operand:HI 1 "general_operand" ""))]
  3451.   ""
  3452.   "
  3453. { extern rtx get_unaligned_address ();
  3454.  
  3455.   /* If the output is not a register, the input must be.  */
  3456.   if (GET_CODE (operands[0]) == MEM)
  3457.     operands[1] = force_reg (HImode, operands[1]);
  3458.  
  3459.   /* Handle four memory cases, unaligned and aligned for either the input
  3460.      or the output.  The only case where we can be called during reload is
  3461.      for aligned loads; all other cases require temporaries.  */
  3462.  
  3463.   if (GET_CODE (operands[1]) == MEM
  3464.       || (GET_CODE (operands[1]) == SUBREG
  3465.       && GET_CODE (SUBREG_REG (operands[1])) == MEM)
  3466.       || (reload_in_progress && GET_CODE (operands[1]) == REG
  3467.       && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER)
  3468.       || (reload_in_progress && GET_CODE (operands[1]) == SUBREG
  3469.       && GET_CODE (SUBREG_REG (operands[1])) == REG
  3470.       && REGNO (SUBREG_REG (operands[1])) >= FIRST_PSEUDO_REGISTER))
  3471.     {
  3472.       if (aligned_memory_operand (operands[1], HImode))
  3473.     {
  3474.       rtx aligned_mem, bitnum;
  3475.       rtx scratch = (reload_in_progress
  3476.              ? gen_rtx (REG, SImode, REGNO (operands[0]))
  3477.              : gen_reg_rtx (SImode));
  3478.  
  3479.       get_aligned_mem (operands[1], &aligned_mem, &bitnum);
  3480.  
  3481.       emit_insn (gen_aligned_loadhi (operands[0], aligned_mem, bitnum,
  3482.                      scratch));
  3483.     }
  3484.       else
  3485.     {
  3486.       rtx addr
  3487.         = force_reg (DImode,
  3488.              force_operand (get_unaligned_address (operands[1]),
  3489.                     NULL_RTX));
  3490.       rtx scratch1 = gen_reg_rtx (DImode);
  3491.       rtx scratch2 = gen_reg_rtx (DImode);
  3492.       rtx scratch3 = gen_reg_rtx (DImode);
  3493.  
  3494.       rtx seq = gen_unaligned_loadhi (operands[0], addr, scratch1,
  3495.                       scratch2, scratch3);
  3496.  
  3497.       alpha_set_memflags (seq, operands[1]);
  3498.       emit_insn (seq);
  3499.     }
  3500.  
  3501.       DONE;
  3502.     }
  3503.  
  3504.   else if (GET_CODE (operands[0]) == MEM
  3505.        || (GET_CODE (operands[0]) == SUBREG 
  3506.            && GET_CODE (SUBREG_REG (operands[0])) == MEM)
  3507.        || (reload_in_progress && GET_CODE (operands[0]) == REG
  3508.            && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)
  3509.        || (reload_in_progress && GET_CODE (operands[0]) == SUBREG
  3510.            && GET_CODE (SUBREG_REG (operands[0])) == REG
  3511.            && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
  3512.     {
  3513.       if (aligned_memory_operand (operands[0], HImode))
  3514.     {
  3515.       rtx aligned_mem, bitnum;
  3516.       rtx temp1 = gen_reg_rtx (SImode);
  3517.       rtx temp2 = gen_reg_rtx (SImode);
  3518.  
  3519.       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
  3520.  
  3521.       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
  3522.                     temp1, temp2));
  3523.     }
  3524.       else
  3525.     {
  3526.       rtx temp1 = gen_reg_rtx (DImode);
  3527.       rtx temp2 = gen_reg_rtx (DImode);
  3528.       rtx temp3 = gen_reg_rtx (DImode);
  3529.       rtx temp4 = gen_reg_rtx (DImode);
  3530.       rtx temp5 = gen_reg_rtx (DImode);
  3531.       rtx temp6 = gen_reg_rtx (DImode);
  3532.       rtx temp7 = gen_reg_rtx (DImode);
  3533.       rtx temp8 = gen_reg_rtx (DImode);
  3534.       rtx temp9 = gen_reg_rtx (DImode);
  3535.  
  3536.       rtx seq = gen_unaligned_storehi (get_unaligned_address (operands[0]),
  3537.                        operands[1], temp1, temp2,temp3,
  3538.                        temp4, temp5, temp6,temp7,
  3539.                        temp8, temp9);
  3540.  
  3541.       alpha_set_memflags (seq, operands[0]);
  3542.       emit_insn (seq);
  3543.     }
  3544.  
  3545.       DONE;
  3546.     }
  3547. }")
  3548.  
  3549. ;; Here are the versions for reload.  Note that in the unaligned cases
  3550. ;; we know that the operand must not be a pseudo-register because stack
  3551. ;; slots are always aligned references.
  3552.  
  3553. (define_expand "reload_inqi"
  3554.   [(parallel [(match_operand:QI 0 "register_operand" "=r")
  3555.           (match_operand:QI 1 "unaligned_memory_operand" "m")
  3556.           (match_operand:TI 2 "register_operand" "=&r")])]
  3557.   ""
  3558.   "
  3559. { extern rtx get_unaligned_address ();
  3560.   rtx addr = get_unaligned_address (operands[1]);
  3561.   /* It is possible that one of the registers we got for operands[2]
  3562.      might coincide with that of operands[0] (which is why we made
  3563.      it TImode).  Pick the other one to use as our scratch.  */
  3564.   rtx scratch = gen_rtx (REG, DImode,
  3565.              REGNO (operands[0]) == REGNO (operands[2]) 
  3566.              ? REGNO (operands[2]) + 1 : REGNO (operands[2]));
  3567.   rtx seq = gen_unaligned_loadqi (operands[0], addr, scratch,
  3568.                   gen_rtx (REG, DImode, REGNO (operands[0])));
  3569.  
  3570.   alpha_set_memflags (seq, operands[1]);
  3571.   emit_insn (seq);
  3572.   DONE;
  3573. }")
  3574.  
  3575. (define_expand "reload_inhi"
  3576.   [(parallel [(match_operand:HI 0 "register_operand" "=r")
  3577.           (match_operand:HI 1 "unaligned_memory_operand" "m")
  3578.           (match_operand:TI 2 "register_operand" "=&r")])]
  3579.   ""
  3580.   "
  3581. { extern rtx get_unaligned_address ();
  3582.   rtx addr = get_unaligned_address (operands[1]);
  3583.   rtx scratch1 = gen_rtx (REG, DImode, REGNO (operands[2]));
  3584.   rtx scratch2 = gen_rtx (REG, DImode, REGNO (operands[2]) + 1);
  3585.   rtx seq;
  3586.  
  3587.   if (GET_CODE (addr) != REG)
  3588.     {
  3589.       emit_insn (gen_rtx (SET, VOIDmode, scratch2, addr));
  3590.       addr = scratch2;
  3591.     }
  3592.       
  3593.   seq = gen_unaligned_loadhi (operands[0], addr, scratch1, scratch1, scratch2);
  3594.   alpha_set_memflags (seq, operands[1]);
  3595.   emit_insn (seq);
  3596.   DONE;
  3597. }")
  3598.  
  3599. (define_expand "reload_outqi"
  3600.   [(parallel [(match_operand:QI 0 "any_memory_operand" "=m")
  3601.           (match_operand:QI 1 "register_operand" "r")
  3602.           (match_operand:TI 2 "register_operand" "=&r")])]
  3603.   ""
  3604.   "
  3605. { extern rtx get_unaligned_address ();
  3606.  
  3607.   if (aligned_memory_operand (operands[0], QImode))
  3608.     {
  3609.       rtx aligned_mem, bitnum;
  3610.  
  3611.       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
  3612.  
  3613.       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
  3614.                     gen_rtx (REG, SImode, REGNO (operands[2])),
  3615.                     gen_rtx (REG, SImode,
  3616.                          REGNO (operands[2]) + 1)));
  3617.     }
  3618.   else
  3619.     {
  3620.       rtx addr = get_unaligned_address (operands[0]);
  3621.       rtx scratch1 = gen_rtx (REG, DImode, REGNO (operands[2]));
  3622.       rtx scratch2 = gen_rtx (REG, DImode, REGNO (operands[2]) + 1);
  3623.       rtx scratch3 = scratch1;
  3624.       rtx seq;
  3625.  
  3626.       if (GET_CODE (addr) == REG)
  3627.     scratch1 = addr;
  3628.  
  3629.       seq = gen_unaligned_storeqi (addr, operands[1], scratch1,
  3630.                    scratch2, scratch3);
  3631.       alpha_set_memflags (seq, operands[0]);
  3632.       emit_insn (seq);
  3633.     }
  3634.  
  3635.   DONE;
  3636. }")
  3637.  
  3638. (define_expand "reload_outhi"
  3639.   [(parallel [(match_operand:HI 0 "any_memory_operand" "=m")
  3640.           (match_operand:HI 1 "register_operand" "r")
  3641.           (match_operand:TI 2 "register_operand" "=&r")])]
  3642.   ""
  3643.   "
  3644. { extern rtx get_unaligned_address ();
  3645.  
  3646.   if (aligned_memory_operand (operands[0], HImode))
  3647.     {
  3648.       rtx aligned_mem, bitnum;
  3649.  
  3650.       get_aligned_mem (operands[0], &aligned_mem, &bitnum);
  3651.  
  3652.       emit_insn (gen_aligned_store (aligned_mem, operands[1], bitnum,
  3653.                     gen_rtx (REG, SImode, REGNO (operands[2])),
  3654.                     gen_rtx (REG, SImode,
  3655.                          REGNO (operands[2]) + 1)));
  3656.     }
  3657.   else
  3658.     {
  3659.       rtx addr = get_unaligned_address (operands[0]);
  3660.       rtx scratch1 = gen_rtx (REG, DImode, REGNO (operands[2]));
  3661.       rtx scratch2 = gen_rtx (REG, DImode, REGNO (operands[2]) + 1);
  3662.       rtx scratch_a = GET_CODE (addr) == REG ? addr : scratch1;
  3663.       rtx seq;
  3664.  
  3665.       seq = gen_unaligned_storehi (addr, operands[1], scratch_a,
  3666.                    scratch2, scratch2, scratch2,
  3667.                    scratch1, scratch2, scratch_a,
  3668.                    scratch1, scratch_a);
  3669.       alpha_set_memflags (seq, operands[0]);
  3670.       emit_insn (seq);
  3671.     }
  3672.  
  3673.   DONE;
  3674. }")
  3675.  
  3676. ;; Subroutine of stack space allocation.  Perform a stack probe.
  3677. (define_expand "probe_stack"
  3678.   [(set (match_dup 1) (match_operand:DI 0 "const_int_operand" ""))]
  3679.   ""
  3680.   "
  3681. {
  3682.   operands[1] = gen_rtx (MEM, DImode, plus_constant (stack_pointer_rtx,
  3683.                              INTVAL (operands[0])));
  3684.   MEM_VOLATILE_P (operands[1]) = 1;
  3685.  
  3686.   operands[0] = const0_rtx;
  3687. }")
  3688.  
  3689. ;; This is how we allocate stack space.  If we are allocating a
  3690. ;; constant amount of space and we know it is less than 4096
  3691. ;; bytes, we need do nothing.
  3692. ;;
  3693. ;; If it is more than 4096 bytes, we need to probe the stack
  3694. ;; periodically. 
  3695. (define_expand "allocate_stack"
  3696.   [(set (reg:DI 30)
  3697.     (plus:DI (reg:DI 30)
  3698.          (match_operand:DI 0 "reg_or_cint_operand" "")))]
  3699.   ""
  3700.   "
  3701. {
  3702.   if (GET_CODE (operands[0]) == CONST_INT
  3703.        && INTVAL (operands[0]) < 32768)
  3704.     {
  3705.       if (INTVAL (operands[0]) >= 4096)
  3706.     {
  3707.       /* We do this the same way as in the prologue and generate explicit
  3708.          probes.  Then we update the stack by the constant.  */
  3709.  
  3710.       int probed = 4096;
  3711.  
  3712.       emit_insn (gen_probe_stack (GEN_INT (- probed)));
  3713.       while (probed + 8192 < INTVAL (operands[0]))
  3714.         emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192))));
  3715.  
  3716.       if (probed + 4096 < INTVAL (operands[0]))
  3717.         emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[0]))));
  3718.     }
  3719.  
  3720.       operands[0] = GEN_INT (- INTVAL (operands[0]));
  3721.     }
  3722.   else
  3723.     {
  3724.       rtx out_label = 0;
  3725.       rtx loop_label = gen_label_rtx ();
  3726.       rtx want = gen_reg_rtx (Pmode);
  3727.       rtx tmp = gen_reg_rtx (Pmode);
  3728.       rtx memref;
  3729.  
  3730.       emit_insn (gen_subdi3 (want, stack_pointer_rtx,
  3731.                  force_reg (Pmode, operands[0])));
  3732.       emit_insn (gen_adddi3 (tmp, stack_pointer_rtx, GEN_INT (-4096)));
  3733.  
  3734.       if (GET_CODE (operands[0]) != CONST_INT)
  3735.     {
  3736.       out_label = gen_label_rtx ();
  3737.       emit_insn (gen_cmpdi (want, tmp));
  3738.       emit_jump_insn (gen_bgeu (out_label));
  3739.     }
  3740.  
  3741.       emit_label (loop_label);
  3742.       memref = gen_rtx (MEM, DImode, tmp);
  3743.       MEM_VOLATILE_P (memref) = 1;
  3744.       emit_move_insn (memref, const0_rtx);
  3745.       emit_insn (gen_adddi3 (tmp, tmp, GEN_INT(-8192)));
  3746.       emit_insn (gen_cmpdi (tmp, want));
  3747.       emit_jump_insn (gen_bgtu (loop_label));
  3748.       memref = gen_rtx (MEM, DImode, want);
  3749.       MEM_VOLATILE_P (memref) = 1;
  3750.       emit_move_insn (memref, const0_rtx);
  3751.  
  3752.       if (out_label)
  3753.     emit_label (out_label);
  3754.  
  3755.       emit_move_insn (stack_pointer_rtx, want);
  3756.  
  3757.       DONE;
  3758.     }
  3759. }")
  3760.